Updating Tiles Using a Scheduled Task Agent

The background agent for the sample is the TaskScheduler class, which is a subclass of the ScheduledTaskAgent class. TaskScheduler is registered using the WMAppManifest.xml file.

As you saw earlier, a periodic task is registered in the TodoItemViewModel class. This causes the TaskScheduler.OnInvoke method to be called periodically. The OnInvoke method determines what kind of task is being launched by the OS, either periodic or resource intensive. For the to-do sample, it is always a periodic task (see Listing 32.9).

LISTING 32.9. TaskScheduler OnInvoke Method (excerpt)

protected override void OnInvoke(ScheduledTask task){    /* Detect if the task is periodic or resource ...

Get Windows® Phone 8 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.