当我打开我的电脑时执行一个后台任务- Windows商店应用程序

本文关键字:后台任务 一个 Windows 应用程序 我的 电脑 执行 | 更新日期: 2023-09-27 18:10:27

我的应用程序在Windows 8.1 Pro的平板电脑上运行。

我得到了锁屏访问调用:

  await BackgroundExecutionManager.RequestAccessAsync();

一个时间触发器运行我的后台任务与这些条件(Internet和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();

它工作正常,但当我关闭我的设备,它不会再次启动。

如果可以的话,我需要添加哪些条件?

msdn

当我打开我的电脑时执行一个后台任务- Windows商店应用程序

同样的问题

为了将来的使用,我添加了另一个带有会话条件的系统触发器的后台任务来修复它。