DCSIMG
Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8) - Alex Golesh's Blog About Silverlight Development

Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8)

The Windows Phone RTM operating system had only one active application and when application were sent to the background the state was serialized and kept in the application’s isolated storage. This process called tombstoning and application in such state called tombstoned. When user return to the tombstoned application, he would have to wait a while as the application deserialized its state and recovered and we as developers had to take care about saving the application’s state and resuming it.

With Mango that is no longer the case: there is only one active (foreground) application, but once an application is sent to the background the operating system keeps its image alive in memory for as long as possible without impairing the performance of the currently active application. This new state of the application called dormant. When user reactivate the dormant application, the experience would be virtually instantaneous as restoring the application’s in-memory image is a fast operation. In case the dormant application’s memory need to be released to ensure active application performance doesn’t hurt, Mango will tombstone the dormant application and user will have to wait to get back to the application as it was in RTM. This new mechanism is called Fast Application Switching (FAS).

This (short) post shows how to be aware of the manner in which your application was restored after being deactivated. When application is activated, ActivatedEventArgs has new property IsApplicationInstancePreserved which indicates the latest state of resumed application. If IsApplicationInstancePreserved is true this means, that all application memory is intact and virtually nothing should be done in such case. If IsApplicationInstancePreserved is false then we need to take care of “old-styled” tombstoning resume:

private void Application_Activated(object sender, ActivatedEventArgs e)
{
    // Ensure that application state is restored appropriately
    if (!e.IsApplicationInstancePreserved)
    {
        WasTombstoned = true;

        //Your code to resume from tombstoning
        ...
    }
    else
    {
        WasTombstoned = false;
    }
}

That’s almost it. The default behavior of the Mango application lifecycle manager is to preserve application images in memory as long as possible and the tombstoning process will occur automatically by phone’s operation system when it really needed. But how to check/debug resuming from tombstoning this process with emulator when it has only one application running?

The new version of developer tools allow us to force an application to forego FAS in favor of tombstoning. To force tombstoning, open project’s properties and navigate to the “Debug” tab:

image

Ticking the checkbox that says “Tombstone upon deactivation while debugging” will force your application consistently perform tombstoning upon deactivation while the debugger is attached. Clear the checkbox to have the application use FAS again.

Stay tuned to part 7 – Silverlight & XNA interoperability

Alex

Published Tuesday, May 24, 2011 8:43 PM by Alex Golesh

Comments

# The Morning Brew - Chris Alcock » The Morning Brew #859

Pingback from  The Morning Brew - Chris Alcock  » The Morning Brew #859

Wednesday, May 25, 2011 10:45 AM by The Morning Brew - Chris Alcock » The Morning Brew #859

# The Morning Brew - Chris Alcock » The Morning Brew #859

Pingback from  The Morning Brew - Chris Alcock  » The Morning Brew #859

Wednesday, May 25, 2011 10:45 AM by The Morning Brew - Chris Alcock » The Morning Brew #859

# The Busy Developers Guide to Mango. | WP7 Developers Links

Pingback from  The Busy Developers Guide to Mango. | WP7 Developers Links

# Alex Golesh's Windows Phone Mango – What’s New Series | Ginktage

Pingback from  Alex Golesh's Windows Phone Mango – What’s New Series | Ginktage

# Alex Golesh's Windows Phone Mango – What’s New Series | Ginktage

Pingback from  Alex Golesh's Windows Phone Mango – What’s New Series | Ginktage

# Alex Golesh's Windows Phone Mango – What’s New Series | Ginktage

Pingback from  Alex Golesh's Windows Phone Mango – What’s New Series | Ginktage

# Dev Dude’s Guide to Mango Series – “Windows Phone Mango???What???s New?” in 8 parts (Think “Code trucks filled with many Mango’s”) | gong

Pingback from  Dev Dude’s Guide to Mango Series – “Windows Phone Mango???What???s New?” in 8 parts (Think “Code trucks filled with many Mango’s”) | gong

# Was ist neu im Mango SDK | Biggle's Blog

Pingback from  Was ist neu im Mango SDK | Biggle's Blog

Thursday, June 09, 2011 9:52 AM by Was ist neu im Mango SDK | Biggle's Blog

# re: Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8)

I'll try to put this to good use immeidaetly.

Friday, July 01, 2011 6:26 AM by Hawk

# Windows 8 Consumer Preview and Visual Studio 11 Beta – Process Lifetime Management (Part 11/11)

Windows 8 Metro applications introduces new (for desktop version of Windows) philosophy behind application

Wednesday, February 29, 2012 10:46 PM by Alex Golesh's Blog About Silverlight Development

# Windows 8 Consumer Preview and Visual Studio 11 Beta – Process Lifetime Management (Part 11/11)

Windows 8 Metro applications introduces new (for desktop version of Windows) philosophy behind application

Wednesday, February 29, 2012 11:07 PM by Community Blogs

# re: Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8)

Hurrah! After all I got a website from where I know how to actually take helpful facts concerning my study and knowledge.

Sunday, June 24, 2012 10:20 AM by Coombs

# re: Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8)

Hi, I do believe this is a great blog. I stumbledupon it ;) I'm going to come back yet again since I book marked it. Money and freedom is the greatest way to change, may you be rich and continue to help other people.

Monday, July 30, 2012 2:48 AM by Moore

# re: Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8)

It's very effortless to find out any topic on web as compared to books, as I found this paragraph at this web page.

Friday, August 03, 2012 11:29 AM by Fox

# re: Windows Phone Mango–What’s New? (“Fast Application Switch (FAS)” - Part 6 of 8)

היי

אחלה פוסט, תודה!

Sunday, August 05, 2012 9:30 PM by Soper

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: