Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AnimationRunner.cs
1using System;
2using System.Threading;
3using System.Threading.Tasks;
4using Microsoft.Maui.ApplicationModel;
5using Microsoft.Maui.Controls;
6
8{
12 public static class AnimationRunner
13 {
21 public static async Task RunAsync(VisualElement Target, Func<CancellationToken, Task> Execute, CancellationToken Token)
22 {
23 ArgumentNullException.ThrowIfNull(Target);
24 ArgumentNullException.ThrowIfNull(Execute);
25
26 if (!Token.CanBeCanceled)
27 {
28 await Execute(CancellationToken.None);
29 return;
30 }
31
32 using CancellationTokenRegistration Registration = Token.Register(() =>
33 {
34 MainThread.BeginInvokeOnMainThread(() => Microsoft.Maui.Controls.ViewExtensions.CancelAnimations(Target));
35 });
36
37 await Execute(Token);
38 }
39 }
40}
Helper class providing consistent animation execution semantics.
static async Task RunAsync(VisualElement Target, Func< CancellationToken, Task > Execute, CancellationToken Token)
Executes an animation while wiring cancellation tokens to MAUI animation APIs.