Coding Paradox

Blog On .Net, CSharp, Windows Phone Programming

Archive for the ‘Background Agent’ tag

Updating App Tile using Background Agent in Windows Phone 8 App

with one comment

Background Agents and Scheduled Tasks allows your application to execute to code in the background even when the application is not running in the foreground. This is quite useful in various type of scenarios where you want to update the Live Tile frequently, show a toast notification on getting some data from web service, perform some data synchronization etc. In this tutorial we will take a look at how to use Background Agent to update the app tile in Windows Phone 8 application.

The Windows Phone API includes the ScheduledTaskAgent class which can be used to create Background agents which run on periodic schedules. Two types of tasks can be created which are

  • PeriodicTask : This is useful for scenarios which require small time to execute. This is run once every 30 minutes are useful for performing tasks like raising notifications, updating tile etc.
  • ResourceIntensiveTask : This is useful when performing operations which require a long amount of time. This tasks executes for 10 minutes however there are a lot of criteria related to processor activity which must be fulfilled before the task is executed. You can use this while performing lengthy operations like synchronizing data or uploading pictures.

A Windows Phone application can have only one background agent but it can register both PeriodicTask as well as ResourceIntensiveTask. If an application registers both the type of tasks, there are both executed at different intervals. The tasks can use a limited amount of memory which is around 11 MB at a given time. If memory usage increase, the task is immediately terminated. If the agents terminated two consecutive times due to unhandled exceptions, they are automatically removed from schedule. Read the rest of this entry »

Written by Mako

June 1st, 2014 at 3:26 pm