Guidelines and checklist for background tasks (Windows Store apps using JavaScript and HTML)

Language: JavaScript and HTML | VB/C#/C++ and XAML
0 out of 1 rated this helpful - Rate this topic

Create better background tasks to support your Windows Store app and ensure your app meets the requirements for running background tasks.

Background task guidance

Consider the following guidance when developing your background task, and before publishing your app.

Close your background tasks:  Don't forget that the background task needs to call the close() method when it's done. If the background task doesn't close itself, the process running the background task can continue to consume memory and battery life even though the background task completed or was cancelled.
CPU and network quotas:  Don't exceed the CPU quota or network data usage quota applied to your background task. Background tasks should be lightweight to save battery life and provide a better user experience for foreground apps. See Supporting your app with background tasks for the resource constraints applied to background tasks.
Manage background tasks:  Your app should get a list of registered background tasks, register for progress and completion handlers, and handle those events appropriately. Your background tasks should report progress, cancellation, and completion. See How to get a list of pending background tasks, How to handle a cancelled background task, and How to monitor background task progress and completion.
Update the app manifest:  Declare each background task in the application manifest, along with the type of triggers it is used with. Otherwise your app will not be able to register the background task at runtime. For more information, see How to declare background tasks in the application manifest.
Prepare for app updates:  If your app will be updated, create and register a ServicingComplete background task (see SystemTriggerType) to help perform app updates that may be necessary outside the context of running in the foreground.
Background tasks for lock screen-capable apps:  The lock screen is a shared resource. Only seven apps may be placed on the lock screen at any one time, and only one may show a wide tile. Your app can provide a good user experience by requesting lock screen access using the RequestAccessAsync method, and by making sure your app will still work without being on the lock screen. Apps that are not placed on the lock screen can still update tiles, update badges, send notifications, and register for system event triggers. The user experience when your app is in the foreground should never be disrupted even if the user has not placed your app on the lock screen.

Read the Lock screen overview to get a sense for whether or not the lock screen is the right place for your app.

Background task checklist

The following checklist applies to all background tasks.

  • Associate your background task with the correct trigger.

  • Add conditions to help ensure your background task runs successfully.

  • Handle background task progress, completion, and cancellation.

  • Do not display UI other than toasts, tiles, and badge updates from the background task.

  • Call close() when the background task is done working.

  • Use persistent storage to share data between the background task and the app.

  • Declare each background task in the application manifest, along with the type of triggers it is used with. Make sure the entry point and trigger types are correct.

  • Write background tasks that are short-lived. Don't exceed the CPU or network quotas shown in Supporting your app with background tasks.

  • Do not rely on user interaction in background tasks.

Background task checklist for lock screen-capable apps

Follow this guidance when developing background tasks for apps that are capable of being on the lock screen. Follow the guidance in Guidelines and checklist for lock screen tiles.

  • Make sure your app needs to be on the lock screen before developing it as lock screen-capable. For more info see Lock screen overview.

  • Make sure your app will still work without being on the lock screen.

  • Request lock screen access using the RequestAccessAsync method.

  • Include a background task registered with TimeTrigger and declare it in the app manifest. Make sure the entry point and trigger types are correct. This is required for certification, and enables the user to place the app on the lock screen.

  • Write background tasks that are short-lived, even for lock screen-capable apps. Don't exceed the CPU or network quotas shown in Supporting your app with background tasks.

Related topics

Other related background task topics
Quickstart: Create and register a background task
How to register a background task
How to debug a background task
How to declare background tasks in the application manifest
How to trigger suspend, resume, and background events in Windows Store apps (when debugging)
Other related lock screen guidance
Lock screen overview
Displaying tiles on the lock screen
Guidelines and checklist for lock screen tiles

 

 

Build date: 10/26/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.