Performance Zone is brought to you in partnership with:

Gil Fink, Microsoft MVP, is an expert in Web development and Microsoft data platform. He works as a senior architect at Sela Group. He is currently consulting for various enterprises and companies, where he architects and develops Web and RIA-based solutions. He conducts lectures and workshops for developers and enterprises who want to specialize in infrastructure and Web development. He is also a co-author of several Microsoft Official Courses and training kits. You can read his publications at his blog: http://blogs.microsoft.co.il/blogs/gilf. Gil is a DZone MVB and is not an employee of DZone and has posted 150 posts at DZone. You can read more from them at their website. View Full User Profile

Debugging Windows Store app Background Tasks

01.01.2013
| 1427 views |
  • submit to reddit

 Windows Store apps can run operations in the background using background tasks. Background tasks are triggered using a background triggers like time or system maintenance. That raises a question which is how we can debug background tasks.

Visual Studio 2012 to the Rescue

Visual Studio 2012 can help you trigger a background task manually. First you need to add a breakpoint to the background task code that you want to check. After you set your breakpoint, you can trigger the background task using the Suspend drop down menu (part of the Debug Location toolbar). The Suspend drop down menu shows all the background tasks associated with the running app. In the next figure you can see the MyBackgroundTask task available in the suspend drop down menu:

Background Task in the suspend menu

Pressing the background task name will manually trigger the task.

Manually triggered Background Task

Pay attention that if the background task isn’t registered nothing will happen and you won’t be able to debug it. 

That is it and now you can debug your code.

Summary

Visual Studio 2012 includes a feature that enables background task debugging. Knowing that can help you avoid waiting to trigger events to happen.

Published at DZone with permission of Gil Fink, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)