Hi there,
I'm trying to loop a Xamarin.Forms.Image.FadeTo() animation.
I want to fadeTo(0,1000,Easing.Linear)
and after that i want to FadeTo(1, 1000, Easing.Linear)
in an endless loop that can be canceled from outside.
I tried:
Task.Run(async () =>
{
while (!cancelConnectionAnimation.Token.IsCancellationRequested)
{
Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
{
System.Diagnostics.Debug.WriteLine("Fadeout");
await imgConnectionState.FadeTo(0, 1000, Easing.Linear);
System.Diagnostics.Debug.WriteLine("Fadein");
await imgConnectionState.FadeTo(1, 1000, Easing.Linear);
});
await Task.Delay(2000);
}
}, cancelConnectionAnimation.Token);
That does work, but I realy don't want to use Task.Delay() because it seems to me like a workaround.
Is it possible to await these tasks, so that i don't need to Delay the calling task?
It seems like an easy problem but unfortunatelly i could not find a way to await these mainthread tasks.
Thanks in advance.
Alex