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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.