Introduction
In this article we will described the life
cycle of Metro Style Application. I hope you people would be familiar with
ASP.Net application life cycle and ASP.Net page life cycle. Life cycle of a
application contain whole the process from which a application start and to the
end of application. Metro Style Application life cycle has mainly three state.
- Not Running
- Running
- Suspended
An app can be suspended when the user switches
away from it or when Windows enters a low power state. While your app is
suspended, it continues to reside in memory so that users can quickly and
reliably switch to it.
While your app is suspended, it can be resumed
at any time. Windows can also terminate it at any time to free up memory for
other apps or to save power.
When your app is suspended and then resumed, it
looks as though it has been running the entire time. When your app is
terminated, it stops running and is unloaded from memory. Windows notifies your
app when it suspends it, but doesn't provide additional notification when it
terminates the app. That means your app should handle the suspended event and
use it to save its state, and release its exclusive resources and file handles
immediately.
App Launch/ Not Running State
An app is launched whenever it is activated by
the user but the process is in the Not Running state, because it
was just deployed.When an app is launched, Windows displays a splash screen for
the app. While its splash screen is displayed, an app should ensure that it's
ready for its user interface to be displayed to the user. The primary tasks for
the app are to register event handlers and set up any custom UI it needs for
loading. These tasks should only take a few seconds. If an app needs to request
data from the network or needs to retrieve large amounts of data from disk,
these activities should be completed outside of activation. An app can use its
own custom loading UI or an extended splash screen while it waits for these long
running operations to finish.
App Activation/ Running State
After the app completes activation, it enters
the Running state and the splash screen is torn down. Showing a
window, returning from the activation handler, and completing a deferral are
specific ways that an app completes activation.
App Suspended State
An app can be suspended when the user switches
away from it or when Windows enters a low power state. Most apps stop running
when the user switches away from them.
When the user moves an app to the background,
Windows waits a few seconds to see whether the user immediately switches back to
the app. If the user does not switch back, Windows suspends the app.
If an app has registered an event handler for
the Suspending | suspending event, this event handler is called
right before the app is suspended. You can use the event handler to save
relevant app and user data to persistent storage. We recommended that you use
the application data APIs for this purpose because they are guaranteed to
complete before the app enters the Suspended state.