Yasser Lima
Yasser Lima

Reputation: 55

Constantly run a background task in Windows 8 Store apps

I'm trying to make an app that can be able to warn the user about his commitments. The problem is that i don't know how to keep my app constantly monitoring when the commitment will happen, even when the app is not running. Is there any way i can do it on Windows 8?

Obs. I need to do it in Windows 8, not Windows 8.1.

Upvotes: 0

Views: 854

Answers (1)

dcastro
dcastro

Reputation: 68750

Yes, you can do it with Background Tasks.

You should create a separate project, where you declare a class that implements IBackgroundTask, and then declare it in the app's manifest.

You can find a lot more about it here: http://msdn.microsoft.com/en-us/library/windows/apps/hh977056.aspx On the left panel you'll find all sorts of useful links, "How to declare background tasks in the application manifest" and "How to run a background task on a timer".

Note: Don't forget to use BackgroundTaskDeferral if your task uses async code:

public async void Run(IBackgroundTaskInstance task)
{
    BackgroundTaskDeferral deferral = task.GetDeferral();

    await Something(); //...

    deferral.Complete();
}

Upvotes: 2

Related Questions