Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
internal Task CurrentNavigationTask { get; set; }
public async Task<Page> PopAsync(bool animated)
{
if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
{
var tcs = new TaskCompletionSource<bool>();
Task oldTask = CurrentNavigationTask;
CurrentNavigationTask = tcs.Task;
await oldTask;
Page page = await PopAsyncInner(animated, false);
tcs.SetResult(true);
return page;
}
Task<Page> result = PopAsyncInner(animated, false);
CurrentNavigationTask = result;
return await result;
}
public async Task PushAsync(Page page, bool animated)
{
if (CurrentNavigationTask != null && !CurrentNavigationTask.IsCompleted)
{
var tcs = new TaskCompletionSource<bool>();
Task oldTask = CurrentNavigationTask;
CurrentNavigationTask = tcs.Task;
await oldTask;
await PushAsyncInner(page, animated);
tcs.SetResult(true);
return;
}
CurrentNavigationTask = PushAsyncInner(page, animated);
await CurrentNavigationTask;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment