Reputation: 385
I thought PushAsync should return Task immediately after call(I want to make several actions while new layout is appearing). But for this code
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
Task task = Navigation.PushAsync(newRoot);
Debug.WriteLine(stopwatch.ElapsedMilliseconds + " ms"); // 1000 ms
await task;
Debug.WriteLine(stopwatch.ElapsedMilliseconds + " ms");// 1500 ms
stopwatch.Stop();
first writeline show about 1 second, second writeline called in 0.5 sec after first. How to improve PushAsync so it will return immediately? Thanks
Upvotes: 1
Views: 1542
Reputation: 3678
I have several applications using NavigationPage and have never seen it take a second to request navigation. You don't happen to have have hooked the PushRequested or Pushed events, have you? Those are invoked synchronously and could easily inject a delay if you have complex code in your handlers.
Upvotes: 0
Reputation: 36
PushAsync is an asynchronous method which means it does the task in the background so not to hold up the application and block any of the other resources.
If you require an immediate response you need to use a synchronous method instead of asynchronous.
Upvotes: 1