Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

PopModalAsync & "The underlying Task is already in one of the three final states"

$
0
0

I updated to Xamarin.Forms 1.2.2 Prerelease 2 and now have the following exception when reaching Navigation.PopModalAsync():

System.InvalidOperationException: The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.
  at at System.Threading.Tasks.TaskCompletionSource`1<bool>.ThrowInvalidException () <IL 0x0000a, 0x00047>
  at at System.Threading.Tasks.TaskCompletionSource`1<bool>.SetResult (bool) <IL 0x0000c, 0x00047>
  at at Xamarin.Forms.Platform.Android.Platform/<>c__DisplayClass19.<PresentModal>b__17 (Android.Animation.Animator) <IL 0x00007, 0x0002f>
  at at Xamarin.Forms.Platform.Android.GenericAnimatorListener.OnAnimationEnd (Android.Animation.Animator) <IL 0x0000f, 0x00063>
  at Android.Animation.AnimatorListenerAdapter.n_OnAnimationEnd_Landroid_animation_Animator_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/41933531/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Android.Animation.AnimatorListenerAdapter.cs:96
  at at (wrapper dynamic-method) object.bd322b2b-335d-4b26-8b96-53eb2d2a0cfa (intptr,intptr,intptr) <IL 0x00017, 0x0001f>

This is the code I use:

await Navigation.PushModalAsync(new SplashPage());
await Task.Run(()=> 
{
        DependencyService.Get<IDatabaseHandler>().CreateOrReadDatabase(startingDeck);

        //Task.Delay(500);

});
initEventHandler();
await Navigation.PopModalAsync();

When checking Navigation within the debugger I can actually see that the modalstack is empty.

I noticed when I uncomment Task.Delay the code is sometimes working, but crashing still very often.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>