Background Tasks in Windows 8

Just got finished writing my first app with a background task. There are a few things essential to making it work that aren’t obvious from the documentation today.

The task itself has to be in a separate project from the app project. This project should be a “Class Library (Metro style apps)” and should output a WinMD file, not a DLL (Project properties > Output type). It’s also best to keep all the code that will run as part of the task out of the app project.

Once you get that all set up, it’s a breeze. The debugger has a feature to choose a task and trigger it on demand, making it simple to dig into the tasks at runtime.

This whitepaper was invaluable in figuring out the whole thing and this blog post was useful too.