Aug 26
  • When your application is launched by the user from Start or the installed applications list the user is taken to a consistent user experience. It should be clear to the user that they are in a new application.

  • When your application is activated by the user returning to a previously running application, the user is taken to an experience that  shows when the application was deactivated. The user should not be able to tell that the application was halted and restarted.

  • When the user launches  your application, you should present the user with some information about a previous running instance. It could be a list of recently opened documents for instance. The user should not feel like they are continuing a previous session.

  • The State property of the PhoneApplicationService class should be used  to store transient application state in the Deactivated event handler and to retrieve application state in the Activated handler.

  • The State property of the PhoneApplicationPage class is used to store transient page state in the OnNavigatedFrom event handler and to retrieve the state in the OnNavigatedTo event handler.

  • An application is not guaranteed to be activated after it has been tombstoned. For this reason, you need to save  persistent state to isolated storage both in the Deactivated event handler and in the Closing event handler. To avoid duplicating code, you may want to create a single method that saves persistent data to isolated storage and call the same method from both event handlers.

  • Applications must complete all of the actions in the Deactivated event handler in less than 10 seconds. When 10 seconds has elapsed, the application will be terminated. You should make an effort for this to happen in a much shorter time window when developing your application. If your application state data than can’t be saved in a few seconds, you need to save incrementally while your application is running.

  • If an application relies on data from isolated storage, it is likely that you will want to load this data both in the Launching event handler and in the Activated event handler. To avoid duplicating code, you may want to create a single method that loads persistent data from isolated storage and call the same method from both event handlers.

  • Handlers for the PhoneApplicationService events are stubbed out in the default Windows Phone application project template included with Windows Phone Developer Tools . They are found in the App.xaml.cs file.

  • An instance of PhoneApplicationService class is provided by the default Windows Phone application project template. Access the State dictionary of this class from your application using the following code.

    private void Application_Deactivated(object sender, DeactivatedEventArgs e)
    {
        PhoneApplicationService.Current.State["key"] = "value";
    }
  • Values stored in the State dictionary must be serializable.

  • Invoking a Launcher or Chooser will deactivate your application. To ensure that your application receives receive the result of the Chooser task when your application is reactivated, the Chooser object must be declared with a global scope within the PhoneApplicationPage class and you must initialize the Chooser and assign the Completed event delegate in the PhoneApplicationPage constructor.


    For more information about how to handle the activation and deactivation of your application see, the Execution Model for Windows Phone.

Execution Diagram from MSDN:

IC418879