Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Phone

Windows Phone 8 : Scheduled Tasks - Background Agent Types

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
9/10/2014 4:19:07 AM

Windows Phone supports three types of background agents: ScheduledTaskAgent, AudioPlayerAgent, and AudioStreamingAgent (see Figure 1).

Image

FIGURE 1 BackgroundAgent types.

ScheduledTaskAgent is an abstract class, which you subclass to provide your own logic to be performed whenever the OS chooses to invoke your agent. When invoked, the OS passes the registered task object to the task agent, which allows you to determine what kind of activity is to be performed.

ScheduledTaskAgents handle two kinds of tasks: periodic and resource intensive, which are represented by the PeriodicTask and ResourceIntensiveTask classes, respectively.


Note

An app may have only one periodic task and/or one resource intensive task. If an attempt is made to register more than one of either type, an InvalidOperationException is raised.


Scheduled tasks are registered in the same manner as ScheduledNotification objects—with the ScheduledActionService. At an indeterminate time after registration, the operating system instantiates your task agent and passes it the scheduled task (see Figure 2). The agent performs any processing it needs to do in the background, and then signals that it has either completed its work or that it is unable to complete.

Image

FIGURE 2 Periodic tasks are registered with the ScheduledActionService. The OS invokes the ScheduledTaskAgent, passing it the PeriodicTask object.

It is important to recognize the distinction between the roles of tasks and task agents. Tasks contain information that is passed to the task agent. Their purpose is to allow the ScheduledActionService to determine how and when to run the task agent. The task agent performs the background activity, and that is where you can place your code to be executed in the background.

PeriodicTask and ResourceIntensiveTask are analogous to the ScheduledNotification classes: Alarm and Reminder. ScheduledTask and ScheduledNotification both derive from ScheduledAction, which includes properties for the name and expiration date of the task (see Figure 3).

Image

FIGURE 3 ScheduledTask is derived from ScheduledAction, the same base class for scheduled notifications.

The following sections examine the two ScheduledTask types, PeriodicTask and ResourceIntensiveTask, in greater detail.

Periodic Tasks

A periodic task is used to perform short operations and is allocated a 15-second window to complete its work. Periodic tasks run, at most, every 30 minutes. Typical scenarios for periodic tasks include performing small incremental data synchronization with a cloud service, using geographic location to track the location of the device, or polling a social network cloud service for new messages or status updates.


Note

When retrieving the geographic location of the device within a scheduled task (via a GeoCoordinateWatcher), a cached location value is used instead of real-time data. This helps to minimize the power consumption of background agents. It does, however, also introduce a lag for determining the location of the device, which may be problematic in some scenarios.


Periodic Task Invocation

There are no guarantees that a periodic task will ever run. To minimize resources, the phone OS launches all periodic tasks for all apps on the device at approximately the same time. This can mean that if a large number of periodic tasks are registered, not all will be invoked. Moreover, Battery Saver mode is an option that the user can enable on the device to indicate that battery life should be prioritized. If this mode is enabled, periodic agents may not run, even if the task interval has elapsed.

There is also a limit on the total number of periodic agents that can be scheduled on a device. This limit varies from device to device, but it can be as low as six. If this limit is approached, the user is warned that multiple background agents are running, and that it may cause faster battery consumption.

Resource Intensive Tasks

Resource intensive tasks (also known as on idle tasks) are allocated a substantially longer execution time than periodic tasks. Resource intensive tasks, however, run only when the phone meets a minimum set of requirements relating to processor activity, power source, and network connection type (see Table 1). This task is typically used to synchronize large amounts of data to the phone during periods of inactivity.

Resource intensive tasks typically run for a maximum of 10 minutes. The runtime is cut short, however, if one or more of the requirements that determine eligibility to launch are no longer met.

TABLE 1. Run Eligibility Requirements for Resource Intensive Tasks

Image

Caution

Due to the hefty requirements for resource intensive tasks, it is possible that a resource intensive task may never be launched. Be mindful of this when designing your app, and allow your foreground app to adapt to the absence of any processing that should have taken place in the background but did not.


Other -----------------
- Windows Phone 8 : Windows Phone Toolkit Animated Page Transitions - Reusing the Transition Attached Properties
- Windows Phone 8 : Windows Phone Toolkit Animated Page Transitions - Using Windows Phone Toolkit Transitions
- Windows Phone 8 : Messaging - Composing a New Message (part 8) - Checking for New Mail
- Windows Phone 8 : Messaging - Composing a New Message (part 7) - Adding Emoticons and Clip Art
- Windows Phone 8 : Messaging - Composing a New Message (part 6) - Adding Recipients Through CC and Blind CC
- Windows Phone 8 : Messaging - Composing a New Message (part 5) - Setting Message Priority
- Windows Phone 8 : Messaging - Composing a New Message (part 4) - Removing a Message Attachment
- Windows Phone 8 : Messaging - Composing a New Message (part 3) - Sending a Picture from the Camera
- Windows Phone 8 : Messaging - Composing a New Message (part 2) - Adding Message Attachments
- Windows Phone 8 : Messaging - Composing a New Message (part 1) - Writing a Message
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server