void AppSuspending(object sender, Windows.ApplicationModel.SuspendingEventArgs args) { Windows.ApplicationModel.SuspendingDeferral deferral = args.SuspendingOperation.GetDeferral(); // Unadvise Dispose(true); deferral.Complete(); }
private async void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e) { Windows.ApplicationModel.SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral(); await stopCameraAsync(); deferral.Complete(); }
public PrismApplicationBase() { InternalInitialize(); _logger.Log("[App.Constructor()]", Category.Info, Priority.None); CoreApplication.Exiting += (s, e) => { StopArgs stopArgs = new StopArgs(StopKind.CoreApplicationExiting) { CoreApplicationEventArgs = e }; OnStop(stopArgs); OnStopAsync(stopArgs); }; WindowService.WindowCreatedCallBacks.Add(Guid.Empty, args => { WindowService.WindowCreatedCallBacks.Remove(Guid.Empty); args.Window.Closed += (s, e) => { OnStop(new StopArgs(StopKind.CoreWindowClosed) { CoreWindowEventArgs = e }); OnStopAsync(new StopArgs(StopKind.CoreWindowClosed) { CoreWindowEventArgs = e }).RunSynchronously(); }; SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += async(s, e) => { Windows.Foundation.Deferral deferral = e.GetDeferral(); try { OnStop(new StopArgs(StopKind.CloseRequested) { CloseRequestedPreviewEventArgs = e }); await OnStopAsync(new StopArgs(StopKind.CloseRequested) { CloseRequestedPreviewEventArgs = e }); } finally { deferral.Complete(); } }; }); base.Suspending += async(s, e) => { new SuspensionUtilities().SetSuspendDate(DateTime.Now); Windows.ApplicationModel.SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral(); try { StopArgs stopArgs = new StopArgs(StopKind.Suspending) { SuspendingEventArgs = e }; OnStop(stopArgs); await OnStopAsync(stopArgs); } finally { deferral.Complete(); } }; base.Resuming += async(s, e) => { ResumeArgs resumeArgs = new ResumeArgs { PreviousExecutionState = ApplicationExecutionState.Suspended, }; StartArgs startArgs = new StartArgs(resumeArgs, StartKinds.ResumeInMemory); await InternalStartAsync(startArgs); }; }