I am having a code which handles multiple animations. I want to wait until or know if multiple animations are completed. I am currently using await Task.Delay(1000);
and setting it equal to maximum duration of one of the animations.
Here is my C# Code Behind:
new Animation()
{
{ 0, 1, new Animation(a => dialogControl.FadeTo(1, 1000)) },
{ 0, 1, new Animation(a => dialogControl.ScaleTo(1, 1000)) },
}.Commit(this, "Animation1");
await Task.Delay(1000);
Debug.WriteLine("Do some task after multiple animations are completed");
Is there anyway it would wait until all animations are completed and only proceed then?
CodePudding user response:
from the docs on Commit
public void Commit (Xamarin.Forms.IAnimatable owner,
string name, uint rate = 16, uint length = 250,
Xamarin.Forms.Easing easing = default,
Action<double,bool> finished = default,
Func<bool> repeat = default);
finished
Action<Double,Boolean>
An action to call when the animation is finished.
CodePudding user response:
await Task.WhenAll(
dialogControl.FadeTo(1, 1000),
dialogControl.ScaleTo(1, 1000)
);
Debug.WriteLine("Do some task after multiple animations are completed");