HTML and CSS Reference
In-Depth Information
A suspended application is cached in memory for as long as it is possible, but it is not guaranteed
to stay in memory indefinitely. It may happen that, perhaps running short of memory, Windows
terminates suspended applications. In this case, the user can only restart the application from the tile
if she wants it back.
resuming an application
There's a simple way for a developer to detect whether the application is being run from a tile or a
charm or if it is resumed from a suspended state. The activated event is fired and the ActivationKind
property is set to launch . In addition, if the previousExecutionState is set to terminated, then the
application has been reactivated from suspension. When recovering from suspension, you might want
to retrieve and restore any saved state. The saved state is commonly retrieved from the sessionState
dictionary or from wherever it was stored during suspension. The code below shows where you insert
code during resumption.
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !==
activation.ApplicationExecutionState.terminated) {
// Initialize your application here.
} else {
// Restore application state here.
var data = WinJS.Application.sessionState["location"];
...
}
args.setPromise(WinJS.UI.processAll());
}
};
Using the sessionState dictionary to save data is not mandatory. You can save session data to some
persistent store or you can just find it acceptable that the application restarts with a fresh state every
time. It is mostly up to you, but saving to session state is the most common approach.
Background tasks
In Windows 8, as well as in other mobile platforms, you can have background tasks to perform non-UI
related tasks, such as transfer of data.
A background task is a lightweight class that is associated with a given application and runs
periodically while the application is not running. A background task can be linked to a condition and
will not run until the condition is met.
A background task is also able to display information on the Lock screen. The Lock screen of a
Windows 8 application contains a background image and some information is rendered over that
such as the current time, the network status, and battery power. In addition, a background task can
write some specific text to the lock screen just to provide a quick update about its status.
Search WWH ::




Custom Search