uwp UWP background tasks

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

  • For registering a background task that runs in a seperate process, you have to go to the "Declarations" Tab in the Package.appxmanifest and add a new "Background Task" and set the entry point.
  • Registering a single-process background task can be done by means of BackgroundTaskBuilder, but the application will throw an exception if you register a task twice, so you must check if you have already registered a task.
  • The app must gain authority to register a new task, this can be done by calling BackgroundExecutionManager.RequestAccessAsync(), but make sure that you really have the permission. The call returns the type of access (BackgroundAccessStatus enum) which will indicate whether you have access or not.
  • Tasks registered are kept until the package is uninstalled, but it won't hurt to check the tasks you need on every launch, bug happens!
  • When the application is updated, permission to register a new task is revoked. To keep your app running after an update, especially if you have added a new task register, you have to remove and request the access over, by means of BackgroundAccessManager. One method to know if your app is updated, is to register another task with a SystemTrigger, type of SystemTriggerType.ServicingComplete.


Got any uwp Question?