2. Topics
Platform overview
Multi-Tasking with background agents
Windows Phone Task Manager
Background Notifications
File Transfer Tasks, Music Playback Tasks
3. Platform overview
Intelligent OS and well designed API
Powerful instrumentation and language
Up to date mobile OS
WP7 Marketplace now available for Ukraine
Multitasking
Push notifications
Implementation of social network API
4. Foreground tasks
Normally a windows phone application runs in
the foreground
At any given time one application is running in
the foreground
This is to ensure the best performance and
battery life for the phone user
5. Background agents
Windows Phone application can start a
background agent.
− It is PeriodicTask, ResourceIntensiveTask or both at
same time
− There is only one agent allowed per application
The agent can run only when the main
application is not in the foreground
Agent is not equivalent to foreground
application running in the background
− It's limited in what it can do and the access it has the
processor and other phone facilities
6. Background Agent restriction
The number of Agents allowed to be active at one time is
restricted by the Windows Phone system
If the right conditions do not arise, Agent will not be
started
− The background agents only run in situations where the system feels
able to give them access to the processor
If the phone goes into “Power Saver” mode it may stop
running background agents completely
User can also manage the agents running on their phone
and may chose to disable them
Don't put any critical logic into yours app background
agent
7. Agent and Tasks
A Task is the container that is managed by the
operation system and runs at the appointed
time
It runs an Agent which does the work
− The agent code is called as a method in a class
− The class is created as part of a Scheduled Task Agent
Project
There are two kinds of Task
− Periodic tasks that are runs through a certain period of
time
− Resource intensive tasks that run where the phone in a
position to let them
8. Periodic task agent
A periodic task agent runs every
− Typically every 30 minutes or more, depends on phone
loading
It is intended to perform a task that should be
performed regularly and complete quickly
− The agent is allowed to run for 25 seconds or less
− The phone sets a limit on the maximum number of active
at any time
Good for location tracking, polling background
services etc.
9. Resource intensive agents
Resource intensive agents run where the
phone is in a position where it can usefully
perform some data processing
− Where the phone is powered by the main
− Where the phone is connected to WiFi
− Where the phone is not being used (locked screen
displayed)
A “Resource Intensive”
agent can run for up to
10 minutes
10. Dual purpose agent
It is possible for application to perform both
periodic and resource intensive tasks in the
same time
This can be achieved using a single
background agent class, run from both kind of
task
The agent will run periodically and when phone
is in a position to allow resource intensive work
When the agent starts it can determine the
context in which it is running and then behave
appropriate
11. Background and Foreground
communication
For Periodic and Resource-intensive Agents:
− LINQ 2 SQL, file in isolated storage that is guarded with a
Mutex.
− Avoid IsolatedStorageSettings
For Audio Agents: Store custom data in the Tag
property of the AudioTrack class.
Use methods NotifyConplete or Abort to set
state flag
Toast and Tile notification
13. File transfer tasks
It is also possible to create a background task
to transfer files to and from your application's
isolate storage
The transfers may perform where the
application is not running
File can be downloaded from HTTP or HTTPS
hosts
The system maintains a queue of active
transfers and services
Application can query the state of active
transfer
14. Background transfer policies
There are a set of policies that control transfer
behavior
− Maximum Upload file size: 5Mb
− Maximum Download file size over cellular: 20Mb
− Maximum Downloads file over WiFi: 100Mb
These can be modified by setting the value of
TransferPreferences on the particular transfer
15. Audio Playback Agent
The audio can be streamed
There are no ability to play music from library
(only from application's isolate storage)
16. Conclusion
Use background tasks to perform particular job
DO NOT put any critical logic into yours app
background agent
There are a set of default backgrounds agent
designed for common tasks