This is a mirror of official site: http://jasper-net.blogspot.com/

How to Create / Debug a Background Task in Windows 8 – Part 1

| Wednesday, September 12, 2012
Inline image 1

Finally, after many tries, I’ve been able to find which is the correct way to create, configure and debug a background task in Windows 8. Let’s make a little step backward: like in the Windows Phone world, Windows 8 apps can’t run in the background. In fact, they are automatically suspended after 10 seconds that the app is not in foreground anymore. To override this limitation, Windows 8 has introduced background tasks, that are operations that can be executed in background when a criteria is satisfied: a timer is expired, a push notification is received, the computer status is changed and so on.

The concept should be familiar to Windows Phone developers: Windows Phone 7.5 has introduced the same way to support background operations. The biggest difference is that Windows 8 background tasks are more powerful: in Windows Phone there are only a few background tasks categories (mainly, based on timer events), while in Windows 8 you can create tasks that are executed when many different conditions are satisfied.

The downside is that, in Windows 8, background tasks are not so easy to implement and debug, mainly because a dedicated Visual Studio template is missing (unlike in Windows Phone), so it’s a bit tricky to understand how they work.

The first important thing to keep in mind is that a background task is a separate Visual Studio project, that is part of the same solution that contains the main application. So, the first step is to create a new project, by right clicking on the solution and choosing Add – New project. The template you’re going to use is Windows Runtime Component, inside the Windows Store category.

Read more: DZone
QR: Inline image 2

Posted via email from Jasper-net

0 comments: