BackgroundTask UWP Windows 10 TimeTriggeredTask Example registered but never fired

I am testing a background example using script4, and it never calls Run, I follow the steps and what I see:

1.- After the call

BackgroundTaskRegistration task = builder.Register(); 

Task has Trigger = null

Should it be the trigger specified earlier in

 builder.SetTrigger(trigger); ? 

2.- In theory, when I register a background job, it should appear here EventViewer - BackgroundTaskInfrastructure, but it should not appear here?

3.- To try to debug I Debug Location - Pause the application, but after more than 15 minutes it never appears, it should be simple, how to pause and wait?

I also added inside the Run notification:

 var toastXML = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01); var toastTextElements = toastXML.GetElementsByTagName("text"); toastTextElements.First().AppendChild(toastXML.CreateTextNode("Hello World:")); var toastNotification = new ToastNotification(toastXML); toastNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(30); ToastNotificationManager.CreateToastNotifier().Show(toastNotification); 

But he never appears. How does BackgroundTask work with TimeTrigger?

+4
source share
1 answer

In my case, I have a wait call to the Run BackgroundTask method. After watching the video https://channel9.msdn.com/Events/Windows/Developers-Guide-to-Windows-10-RTM/Background-Execution I find out what I need to call:

  var cost = BackgroundWorkCost.CurrentBackgroundWorkCost; 

And get

  var deferral = taskInstance.GetDeferral(); 

And finally, when my calls end the call:

  deferral.Complete(); 

With this, now he always always fulfills my task, the only problem, and I think that this is not resolved is that I can not call:

  Launcher.LaunchUriAsync(new Uri(favorite.Uri, UriKind.Absolute)); 

maybe the launcher is not allowed, but the toast now appears every 15 minutes.

+4
source

All Articles