WP7 Development Tip of the Day: Understanding Closing

by brad 30. September 2010 13:38

The last few tips have been on activating, launching, and deactivating.  Today we’ll cover Closing.

The Closing event marks the death of an instance of your application.  While an application that has been deactivated can be activated and come back, and application instance that has been closed is kaput.  If the application is opened again, it will be a new instance.

According to MSDN, there is only one way that your application can be closed: the user is on the first page of your application and presses the hardware Back button.  Any other action that makes your application step into the background (pressing the Start button, opening a launcher, the phone timing out) will raise the Deactivating event, not the Closing event.

You should save any persistent data in the Closing event.  Even if you are saving persistent data in the Deactivating event (which you should), you’ll need to do it as well in the Closing event because the Deactivating event will not be called before the Closing event.  There is no need to save transient state because an application instance that is closing will not come back.  The next run of the application will be a new instance.

Other Resources

More Tips

Tags:

WP7 Tip of the Day | Windows Phone

Comments

9/30/2010 5:45:54 PM #

pingback

Pingback from topsy.com

Twitter Trackbacks for
        
        WP7 Development Tip of the Day: Understanding Closing
        [codebadger.com]
        on Topsy.com

topsy.com

10/26/2010 5:55:04 PM #

trackback

Archived Tip of the Day by Category

Archived Tip of the Day by Category

code badger

Comments are closed

About Brad

Brad Tutterow lives in Illinois and works in Missouri. He has 12 years of experience developing web sites and Windows applications using a variety of technologies and is most excited currently about Silverlight, Windows Phone 7, Halo Reach, and Visual Studio 2010.