How to Check Application Returning from Dormant State in Windows Phone 7


What is Fast Application Switching (FAS)?

Imagine application "A" is running and user launches a new application "B". On pressing the hardware back button, the user can return back to application "A". If application "A" gets activated without the "resuming " screen then it can be termed as " Fast Application Switching "

What is dormant state?

In Windows Phone 7.5 version FAS is improved over Windows Phone 7 with the introduction of a new state in the application life cycle called "Dormant state". Whereas in Windows Phone 7.0 version there was no Dormant state and on deactivation, an application directly goes to the Tombstone state.

With the introduction of a dormant state in the application life cycle, the operating system preserve instance of the application in memory unless it is forced to release due to low memory. So at the time of application reactivation as a developer you need to check whether to restore the application or not? If the application is reactivating from a dormant state then there should not be restoration.

Checking Application returning from Dormant state

On the Application Activated event you can check whether application is reactivating from dormant or tombstone state as below,

private void Application_Activated(object sender, ActivatedEventArgs e)
        {

            if (e.IsApplicationInstancePreserved)
            {
 
                // No need to restore the application.
               
// Application is reactivating from dormant state

             }

            else
            {
                // Need to restore the application.
                // Application is reactivating from tombstone state
               
// Read state dictionary and Navigation state to restore memory state

            }
        }

In this way you can check whether application is returning from dormant state. I hope this post is useful. Thanks for reading.
 

Up Next
    Ebook Download
    View all
    Learn
    View all