我有应用程序,它实现了进程中的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工作正常。有什么东西我错过了吗?谢谢。