diff options
author | SunboX <andre.fiedler@me.com> | 2017-07-18 21:51:27 +0300 |
---|---|---|
committer | SunboX <andre.fiedler@me.com> | 2017-07-18 21:51:27 +0300 |
commit | 456e78a317c38381c5ea9571ae183fcff165ba21 (patch) | |
tree | f7340a82f2c364e989089766c8399efe864d183e | |
parent | 993ca974bc1b84f51f2109681fda249d2d54e013 (diff) |
null reference fixback-button-fix-for-uwp
-rw-r--r-- | Source/Windows10/Prism.Windows/PrismApplication.cs | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/Source/Windows10/Prism.Windows/PrismApplication.cs b/Source/Windows10/Prism.Windows/PrismApplication.cs index b1694fd..644c5ae 100644 --- a/Source/Windows10/Prism.Windows/PrismApplication.cs +++ b/Source/Windows10/Prism.Windows/PrismApplication.cs @@ -520,28 +520,32 @@ namespace Prism.Windows /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private async void OnSuspending(object sender, SuspendingEventArgs e) - { - IsSuspending = true; - try - { - var deferral = e.SuspendingOperation.GetDeferral(); - - //Custom calls before suspending. - await OnSuspendingApplicationAsync(); - - //Bootstrap inform navigation service that app is suspending. - NavigationService.Suspending(); - - // Save application state - await SessionStateService.SaveAsync(); - - deferral.Complete(); - } - finally - { - IsSuspending = false; - } - } + { + IsSuspending = true; + try + { + var deferral = e.SuspendingOperation.GetDeferral(); + + //Custom calls before suspending. + await OnSuspendingApplicationAsync(); + + //Bootstrap inform navigation service that app is suspending. + NavigationService?.Suspending(); + + // Save application state + var saveAsync = SessionStateService?.SaveAsync(); + if (saveAsync != null) + { + await saveAsync; + } + + deferral.Complete(); + } + finally + { + IsSuspending = false; + } + } /// <summary> /// Invoked when the application resumes from a suspended state. |