Chapter 32. Conducting Background Activities with Scheduled Actions

,

In This Chapter

Image Alarms and reminders

Image Periodic and resource intensive tasks

Image Debugging scheduled tasks

Image Shell tile deep linking

Image Using a Mutex to access shared resources safely

Image LongListSelector custom grouping keys


The need to perform background processing is not uncommon for Windows Phone apps. The transient nature of the app’s life cycle makes performing some long-running or periodic tasks difficult.

One of Microsoft’s goals with Windows Phone has been to solve the battery life limitations present on other phone platforms. One way that it first did this was to limit the number of apps that could run simultaneously to just one app. This meant that using a cloud service and push notification was the only way to simulate background processing.

Since the introduction of multitasking capabilities in the Windows Phone 7.5 (Mango) release, a limit of one foreground app in execution is still in place*, yet Microsoft introduced a new way to run part of your app in the background.

*. There is one exception to this. Apps that register as a geographic location provider are able to continue running despite there being a different app running in the foreground. For more information, see Chapter 17, “Building Location Aware Apps.”

This chapter looks at the scheduled notification system, which consists of a useful set of classes for setting reminders and alarms, which are able to present a message to the user at a predetermined time regardless of whether your app is running in the foreground.

The chapter then examines the scheduled task system, which extends the principles underpinning the notification system and offers the capability to run your own code in the background. You see how to create a to-do list app, which leverages a local database and updates live tiles from a background agent.

Finally, the chapter delves into a more advanced topic that explains how to use a Mutex to provide safe access to resources shared by your foreground app and your background agent.

The source code for this chapter can be found in the BackgroundAgents.sln solution in the BackgroundAgents directory within the downloadable source code.

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

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