// *** Protected Methods *** protected async void OnSuspending(object sender, ISuspendingEventArgs e) { ISuspendingDeferral deferal = GetDeferral(e); await SuspendServicesAsync(); deferal.Complete(); }
// *** Protected Methods *** protected async void OnSuspending(object sender, ISuspendingEventArgs e) { ISuspendingDeferral deferal = GetDeferral(e); IEnumerable <Task> resumingTasks = registeredServices.Select(service => service.OnSuspending()); await Task.WhenAll(resumingTasks); deferal.Complete(); }
// *** Protected Methods *** protected async void OnSuspending(object sender, ISuspendingEventArgs e) { ISuspendingDeferral deferal = GetDeferral(e); IEnumerable<Task> resumingTasks = registeredServices.Select(service => service.OnSuspending()); await Task.WhenAll(resumingTasks); deferal.Complete(); }
/// <summary> /// Runs a function while also getting a suspension deferral from the Windows Runtime. /// </summary> private static Func <Func <Task>, Task> RunWithDeferral(ISuspendingEventArgs e) { return(async function => { ISuspendingDeferral deferral = e.SuspendingOperation.GetDeferral(); try { await function(); } finally { deferral.Complete(); } }); }
/// <summary> /// Runs a function while also getting a suspension deferral from the Windows Runtime. /// </summary> private static Func<Func<Task>, Task> RunWithDeferral(ISuspendingEventArgs e) { return async function => { ISuspendingDeferral deferral = e.SuspendingOperation.GetDeferral(); try { await function(); } finally { deferral.Complete(); } }; }
public async Task SuspendAsync(ISuspendingEventArgs e) { Navigation.Settings.LastSuspended = DateTime.Now; if (Settings.EnableLifecycleStrategy) { PreviouslySuspended = true; _messengerService.Send(new Messages.SuspendingMessage { EventArgs = e }); // TODO: what to do with multiple views? foreach (var nav in NavigationService.Instances.Select(x => x as INavigationService2)) { await nav.SaveAsync(true); } } }
protected virtual ISuspendingDeferral GetDeferral(ISuspendingEventArgs e) { // NB: Use a virtual method rather than getting the deferral directly to aid testing return e.SuspendingOperation.GetDeferral(); }
protected virtual ISuspendingDeferral GetDeferral(ISuspendingEventArgs e) { // NB: Use a virtual method rather than getting the deferral directly to aid testing return(e.SuspendingOperation.GetDeferral()); }
protected override ISuspendingDeferral GetDeferral(ISuspendingEventArgs e) { return ((MockSuspendingEventArgs)e).GetDeferral(); }
} // Noncompliant private async void OnSuspending(object sender, ISuspendingEventArgs e) { } // Compliant - ends with EventArgs and 1st param is object sender
private async void OnSuspending(object sender, ISuspendingEventArgs e) { }
async void MyOtherMethod1(object o, ISuspendingEventArgs args) { }
// *** Overriden base methods *** protected override ISuspendingDeferral GetDeferral(ISuspendingEventArgs e) { return(((MockSuspendingEventArgs)e).GetDeferral()); }
// *** Methods *** public void Suspend(ISuspendingEventArgs e) { base.OnSuspending(null, e); }
async void MyOtherMethod1(object o, ISuspendingEventArgs args) { await Task.Run(() => Console.WriteLine("test")); }
private async void OnSuspending(object sender, ISuspendingEventArgs e) { await Task.Run(() => Console.WriteLine("test")); }
public void Suspend(ISuspendingEventArgs e) { base.OnSuspending(null, e); }