Skip to content

Instantly share code, notes, and snippets.

@rdelrosario
Created March 25, 2022 12:55
Show Gist options
  • Select an option

  • Save rdelrosario/11c1e3956511ad5472f24502db58742c to your computer and use it in GitHub Desktop.

Select an option

Save rdelrosario/11c1e3956511ad5472f24502db58742c to your computer and use it in GitHub Desktop.
public abstract class StartupPage : ContentPage, IStartupTask
{
protected virtual Task<bool> CanRunAsync() => Task.FromResult(true);
protected async Task CompleteAsync()
{
await Navigation.PopModalAsync(false);
_tcs?.SetResult(true);
}
Task<bool> IStartupTask.CanRunAsync() => CanRunAsync();
async Task IStartupTask.RunAsync()
{
_tcs = new TaskCompletionSource<bool>();
await App.Current.MainPage.Navigation.PushModalAsync(this);
await _tcs.Task;
}
private TaskCompletionSource<bool> _tcs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment