Multitasking for Windows Phone 8
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
To help ensure a fast and responsive user experience and to optimize power consumption on the device, in Windows Phone only one app can run in the foreground at a time. However, several features in Windows Phone also give apps the ability to perform actions even when not the active foreground app.
This topic contains the following sections.
- Background audio
- Scheduled tasks
- Background file transfers
- Scheduled notifications
- Fast Application Switching
Windows Phone apps can play audio that continues even when your app is no longer running in the foreground. To accomplish this, you must create an AudioPlayerAgent that continues to run in the background. For more information, see How to play background audio for Windows Phone 8.
Scheduled tasks allow an app to implement an agent that can execute code in the background even when the main app is not running. There are two ways one of these agents can be scheduled. A Periodic Task runs regularly for a short amount of time. A resource-intensive task runs for a longer period of time, but only when the device is in a state where resource-intensive processing will not disrupt the foreground experience. For more information, see Background agents for Windows Phone 8.
Background file transfers
The background transfer service allows an app to queue up multiple HTTP file transfer requests that will continue to be performed when the app is no longer running in the foreground. Both file download and upload are supported. For more information, see Background file transfers for Windows Phone 8.
Scheduled Notifications allow apps to register recurring and one-time alarms and reminders that pop up in the foreground on a predefined schedule. The user experience is similar to the reminders implemented by the built-in calendar app. A user tapping an alarm or reminder launches your app.
Fast Application Switching
In Windows Phone, an app is typically put into a dormant state when the user navigates away. In this state, the app is preserved in memory so that if the user returns to the app, it can resume almost instantly. Apps don’t need to implement any code to enable fast app switching; it is enabled automatically. However, it is still possible that an app will be terminated while it is dormant. It is important that you design your app so that it handles these changes in state that occur throughout the app lifecycle.
Fast Application Switching is supported on lower-memory devices. However, because keeping apps in a dormant state for Fast Application Switching is dependent on the phone’s available memory, an app running on lower-memory devices is terminated and tombstoned more often and more quickly than the same app running on a phone with more memory.