UWP后台任务不适用于Timetrigger,但适用于TimeZoneChange

时间:2017-07-29 17:46:42

标签: c# uwp background-task

我有应用程序,它实现了进程中的backgroundTask。以下代码有效。

            await BackgroundExecutionManager.RequestAccessAsync();
            var builder = new BackgroundTaskBuilder();
            builder.Name = TaskName;
            builder.SetTrigger(new SystemTrigger(SystemTriggerType.TimeZoneChange, false));
            BackgroundTaskRegistration registration = builder.Register();
            registration.Completed += new BackgroundTaskCompletedEventHandler(OnCompleted);

以下代码不起作用。

            await BackgroundExecutionManager.RequestAccessAsync();
            var builder = new BackgroundTaskBuilder();
            builder.Name = TaskName;
            builder.SetTrigger(new TimeTrigger(15, false));
            BackgroundTaskRegistration registration = builder.Register();
            registration.Completed += new BackgroundTaskCompletedEventHandler(OnCompleted);

没有错误也没有崩溃。任务不会被时间触发器触发。 systemTrigger工作正常。有什么东西我错过了吗?谢谢。

0 个答案:

没有答案