Search code examples
c#windowswindows-store-appsbackground-task

Execute a background task when I turn my PC on - Windows Store App


My app is running on a tablet having Windows 8.1 Pro.

I got lock screen access calling this:

  await BackgroundExecutionManager.RequestAccessAsync();

A time trigger run my background task with these conditions (Internet and UserPresent):

         // adding condition
         SystemCondition internetCondition = new SystemCondition(SystemConditionType.InternetAvailable);
         SystemCondition userPresentCondition = new SystemCondition(SystemConditionType.UserPresent); 

         builder.AddCondition(internetCondition);
         builder.AddCondition(userPresentCondition);
         BackgroundTaskRegistration taskRegistration = builder.Register();

it works properly but when I turn off my device, it does not start again.

Which condition shall I add (if it is possible)?

Same question on msdn


Solution

  • for future usage, I fixed it adding another background task with a system trigger with session condition.