locked
Application Lifecycle in 8.1 with NavigationHelper and Network Service resources RRS feed

  • Question

  • Hello

    I have a Win 8.1 C# App that uses default generated NavigationHelper class to Load and Save its State.
    The Problem is that the NavigationHelper SaveState event is triggered from OnNavigatedFrom() Page method and also on Suspend App event.

    In NavigationHelper SaveState callback i release the Network Service resources and there is no coresponding OnResume notification.

    So on the App Resume the Page doesn't have valid Network Service anymore.

    In the NavigationHelper  there is a missing event OnResume to handle App resume.

    peter

    Friday, October 25, 2013 2:58 PM

Answers

  • The app shouldn't do anything destructive (like releasing resources) in SaveState. It should be able to save at any time and continue.

    You should release the resources when suspending and then handle the resuming event to restore them. NavigationHelper doesn't address non-navigation related scenarios like this. You can wire up suspending and resuming yourself, build your own management code, or port the SuspensionManager. Which is best will depend on your app.

    See Launching and resuming apps for more details.

    --Rob

    • Marked as answer by this_peter Thursday, October 31, 2013 2:50 PM
    Tuesday, October 29, 2013 4:23 PM
    Moderator

All replies

  • yes that missing. My solution: Gived the class SuspensionManager an property, IsSaving; set that on true during the SaveAsync. in the OnNavigateFrom i check that property; if its false release the resource (leaving the page) if true dont do anything (because the app is suspending)

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Friday, October 25, 2013 4:02 PM
  • Hi I don't think your solution is right. The App shouldn't make a difference if the Page SaveState comes from OnNavigatedFrom or Suspending. App should release its resources in both cases. What is missing is propagated Resuming event either from SuspensionManager or NavigationHelper. On that event a Page can acquire its resources again.
    Friday, October 25, 2013 7:01 PM
  • The app shouldn't do anything destructive (like releasing resources) in SaveState. It should be able to save at any time and continue.

    You should release the resources when suspending and then handle the resuming event to restore them. NavigationHelper doesn't address non-navigation related scenarios like this. You can wire up suspending and resuming yourself, build your own management code, or port the SuspensionManager. Which is best will depend on your app.

    See Launching and resuming apps for more details.

    --Rob

    • Marked as answer by this_peter Thursday, October 31, 2013 2:50 PM
    Tuesday, October 29, 2013 4:23 PM
    Moderator