The indispensible Windows 8 app developer blog has a new post that shows the nuts and bolts of background tasks, maintenance triggers, and the lock screen. The lock screen is a particularly neat scenario, because your app gets to share a highly visible bit of UI with other important apps:

A demo screenshot of the Windows 8 lock screen, with lock screen apps highlighted in the red box. Microsoft / MSN

Windows PM Hari Pulapaka explains how background tasks and lock screen apps are related:

Because an app uses background tasks to always stay up-to-date even when the user isn’t using their Windows 8 device, the way a user controls what apps can use these background tasks is by granting them permission to appear on the lock screen. This is a natural fit because the lock screen is designed to provide users info about their apps without the need for them to unlock their Windows 8 device. This relationship is a two-way street: your app can use these types of background tasks only if it is on the lock screen and, likewise, your app can appear on the lock screen only if it requests to use these types of background tasks.

And to whet your appetite, the Windows team provides a bit of code to show how easy it is to register your background tasks:

private bool RegisterTimeTriggerBackgroundTask()
BackgroundTaskBuilder builder = new BackgroundTaskBuilder();
builder.Name = "Pop mail background task";
builder.TaskEntryPoint = "MailClient.PopMailBackgroundTask";
// Run every 15 minutes if the device has internet connectivity
IBackgroundTrigger trigger = new TimeTrigger(15, false);
IBackgroundCondition condition =
new SystemCondition(SystemConditionType.InternetAvailable);
IBackgroundTaskRegistration task = builder.Register();

return true;
function registerTimeTriggerBackgroundTask() 
var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder(); = "Pop mail background task";
builder.taskEntryPoint = "js\\popMailBackgroundTask.js";
//Run every 15 minutes if the device has internet connectivity
var trigger = new Windows.ApplicationModel.Background.TimeTrigger(15, false);
var condition = new Windows.ApplicationModel.Background.SystemCondition(
var task = builder.register();

return true;

Lots more goodness: Being productive in the background – background tasks.