Reputation: 323
I'm working with UWP and I wanted to know how could I set an event trigger to execute one background task after the task is registred.
var builder = new BackgroundTaskBuilder();
Debug.WriteLine("Started to Exist");
builder.Name = exampleTaskName;
builder.TaskEntryPoint = "RuntimeComponent1.FirstTask";
var timeTrigger = new TimeTrigger(1, true);
builder.SetTrigger(timeTrigger);
builder.Register();
(My code)
Thanks
Upvotes: 0
Views: 985
Reputation: 15758
According to the code you've posted, you've set wrong FreshnessTime
when you initialized the new instance of a time event trigger. The FreshnessTime
should be larger than 15 minutes or at least equal to 15 minutes.
Note If FreshnessTime is set to less than 15 minutes, an exception is thrown when attempting to register the background task.
For more info, please see TimeTrigger.TimeTrigger constructor or TimeTrigger.FreshnessTime property. And there is also a official Background task sample in GitHub you can refer to.
Upvotes: 0