Running code in the background
You can run a task in the background to perform work when your main app is not running.
Although Windows Store apps can't run while in the background (that is, when they are suspended or terminated), there are specific circumstances when you can run code when your app isn't in the foreground. These include:
- Playing audio
- Uploading or download files
- When a portion of the app, known as a task, is configured to run when certain conditions are met, including a timer event and notifications.
- Updating a live tile with fresh information,
- Updating an item on the lock screen.
Playing audio is a special type of background task. See How to play audio in the background.
Windows 8 uses live tiles (see Tiles, badges, and notifications) to provide up-to-date information. See Quickstart: Update a live tile from a background task for details on refreshing a tile even when your app isn't running.
The Windows 8 lock screen can display up to seven app status icons (such as email, instant messaging and calendar apps). An app that registers to display on the lock screen can refresh its information every fifteen minutes. For example code, see Quickstart: Showing tile and badge updates on the lock screen (Windows Store apps).
- Topics for iOS devs
- Resources for iOS devs
- Windows 8 controls for iOS devs
- Windows 8 cookbook for iOS devs
- Background task topics
- Guidelines for background tasks (Windows Store apps)
- How to debug a background task (Windows Store apps)