Task t = navigation.PushModalAsync(new AuthLoginPage("facebook"));
t.Start();
t.Wait();
How to resolve the exception : System.InvalidOperationException: The Task is not in a valid state to be started.
You can follow this simple usage :-
// When you wanted to start the Async call.
var t = navigation.PushModalAsync(new AuthLoginPage("facebook"));
.
.
// do your other work.
.
.
.
// when you want the result of the Task t that you have started before.
var result =await t; // task will wait here for getting result for you.
You can read more about async/await. it is good to know more about async/await as it is very powerful and easy. look Here for async/await
hope it helps you.
Usually when a method returns a Task, it has already started, so you don't need to explicitly start it.
If you want to wait on its result, utilize await => await t;
. If you want to block on its execution, then call the Result property => t.Result
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.