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 hardware back button user can return back to application “A”. If application “A” gets activated without “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 introduction of new state in application life cycle called “Dormant state”. Whereas in Windows Phone 7.0 version there was no Dormant state and on deactivation application directly goes to Tombstone state.

With introduction of dormant state in application life cycle, 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 application is reactivating from dormant state then there should not be restoration.

Checking Application returning from Dormant state

On 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.

3 responses to “How to check application returning from dormant state in Windows Phone 7”

  1. […] How to check application returning from dormant state in Windows Phone 7 (Dhananjay Kumar) […]

  2. […] How to check application returning from dormant state in Windows Phone 7 […]

  3. […] How to check application returning from dormant state in Windows Phone 7 – @debug_mode at debugmode.net Related Articles:How to work with WrapPanel in Windows Phone 7 by Dhananjay KumarCode to make call […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com