by brad
27. September 2010 14:09
The execution model for a Windows Phone 7 application can be a little confusing. Because of the one-app-at-a-time model for the phone, it’s unlike what we’re used to with desktop client applications. Today’s tip examines Launching and Activating, the two different ways that your app can become the running app.
Launching is the way brand new instances start and can generally happen in one of two ways: The user clicks your application from the list of installed apps or the user clicks your application’s Live Tile on the Start screen. The desktop equivalent is launching a new application from the start menu. When your application is launched, it raises the appropriately named Launching event.
Activating is the term that applies when your application is returned to after the user has been gone for a while. When the user leaves your application, it is deactivated and tombstoned. When the user comes back by using the hardware Back button, your application is activated and raises the Activated event. If you saved transient state, this is where you would read it to restore the user’s experience. The desktop equivalent is alt-tabbing to a previously launched application. This is a shaky analogy since the desktop runs both apps at once and the phone does not, but from a user perspective, the experiences are similar.
These two events in the lifecycle share a couple things in common that it’s good to keep in mind
- These are the the only ways that your application can be started. By definition, an application is either a brand-new instance (launching) or an existing instance (activating).
- You should not read data from isolated storage in either of these two events. This will delay application startup. Instead, read data from isolated storage after the application has loaded and is running.
Other Resources
More Tips