Floating FB popout byF5debug

Handling Background Tasks in Windows Store App - Day 17

In this article we are going to see a new feature of Windows Store application development which is utilizing Background tasks in the app development. In traditional application development the user controls when and how the application is running and positions to see how the application should run in parallel and access the resources and the system. With Windows Store app development, it’s something different that the system checks if the apps are actively running on the user screen or not. If the app is not used, the system will suspend the app in order to maintain performance and preserve system resources for other apps which gives more performance to the device.

In Windows Store app development, Background task is a simple class which are highly configurable and have a significant set of requirements that must be set to register and trigger correctly in the app. Background tasks are implements with IBackgroundTask interface which includes a single run method that passes IBackgroundTaskInstance which gives the task the path to speak with the current running process.

Background tasks are executed at the background to be first assigned to a single trigger which holds the responsibility to decide on how the task should be handled and executed accordingly. Background tasks are in different types that the tasks are triggered based on the need. The below table shows the list of tasks and the description on when to use those.


S No

Trigger Name

Trigger Description



It is responsible for system events which has a huge list of triggering options based on the requirement



It is for time interval or task to trigger based on the time frame scheduled.



It is responsible for when the application is undergoing some maintenance or upgrade


Push Notification

It is for Windows Push Notification Services to send Raw Notifications as and when required


Control Channel

It is for channel communication based on the sockets that are available.


With the list of available triggers, System triggers plays a major role in playing with Background Tasks in your application. System triggers are mainly available with a list of predefined events that can be used to register the task and run in the background. The list of events include

Trigger Name


User Present Triggered when the user is available
User Away Triggered when the user left the session
ControlChannelReset Triggered when control channel is hard resetted
SessionConnected Triggered when the session is connected
LockScreenApplicationAddded Triggered when a title is added to lock screen
LockScreenApplicationRemoved Triggered when a title is removed from the lock screen


Writing your first Background Task Application:

public sealed class MyBackgroundTask : IBackgroundTask

private void UpdateTime()
        // your business code

public void Run(IBackgroundTaskInstance taskInstance)


Background Tasks Best Practices (Microsoft MSDN Suggests)

  • Design background tasks to be short lived.
  • Design the lock screen user experience as described in the “Guidelines and checklists for lock screen tiles.”
  • Do not specify the Executable attribute to ensure the task launches in the system-provided host.
  • Describe the background task class name or JavaScript file name accurately in the manifest.
  • Look in the event viewer for error messages if the background task is not being activated.
  • Use persistent storage to share data between the background task and the app.
  • Register for progress and completion handlers in the app.
  • Register for a background task cancellation handler in the background task class.
  • Register for the ServicingComplete trigger if you expect to update the app.
  • Ensure that the background task class library is referenced in the main project and its output type is winmd.
  • Describe the triggers in the background manifest accurately.
  • Verify if the app needs to be on the lock screen.
  • Do not display UI other than toast, tiles or badges from a background task.
  • Do not rely on user interaction in background tasks.


Hope this gives some clear idea on what Background tasks are all about and how to achieve Background tasks in your Windows Store app development.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

  • Comment
  • Preview

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters


This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter