,

Scheduled Tasks

A scheduled task allows you to perform an activity in the background while your app is or is not running. A task can be used to query a cloud service and update the app’s shell tiles, and it provides your users with the opportunity to respond to some event.

Scheduled tasks follow the same model as scheduled notifications, yet they add one other dimension: user-defined task agents. Whereas scheduled notifications rely solely on built-in task agents for presenting notification dialogs, with scheduled tasks, you define your own.

Like scheduled notifications, scheduled tasks are registered with the ScheduledActionService when your app is running. Registration causes your task agent to run in the background at an indeterminate time and in a separate process.

After a scheduled task is registered, it is persisted across reboots of the OS. The user can view and/or disable background tasks from the Settings screen by navigating to Settings/applications/background tasks (see Figure 32.6).

Image

FIGURE 32.6 The user can disable scheduled tasks via the background tasks screen.

The scheduled task system consists of the following three components:

Image A task registration service called ScheduledActionService, which is the same service used by the scheduled notification system (uses Alarms and Reminders).

Image A background agent that derives from ScheduledTaskAgent, which is used to perform the background activity.

Image The tasks themselves, which can be either of type PeriodicTask or ResourceIntensiveTask. Task objects allow you to pass information to your task agent from your app, determine how the task agent is executed, and when it expires.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.54.7