Background Task in Universal Windows Program - Part Three

Before reading this article, please go through the following articles,

Action Center update plays one of the main roles in background task functionality, especially in mobile or tablet based applications. This is used to update the status message in the notification area without opening the application; the user can read the short status of the updated information just as when new mail arrives in their Inbox or a what’s app message or similar.

How to create Action Center Notification: Please check it out here.

Why is Background Task required for Action Center Update?

Background task is light weight code, and Microsoft has recommended executing the background task code within 30 seconds of wall-clock usage as it should save battery life. If you are in another UI your application may or may not be running in the background, but Action Center is required any time you show an update in the background.

Implement Action Center update

This code has to implement in the Background Task (Windows Runtime component) project.

Go to Background Task component project, implement the code in Run Method.



Rebuild run the application:

Testing

Close the main application. Go to settings -> Time & language -> Date & Time and  change time zone, and background task triggers the changed event.

Windows Desktop update,



Mobile update.



Switch off the Background Task

Microsoft has provided the option to switch off the background task, this option is available in the System settings -> Privacy -> Background apps screen.

Wait is not yet over

Do you remember BackgroundExecutionManager class in part one? Switch off this option in Background apps screen, re-run the code in Debug mode, set  BackgroundExecutionManagerreturn as Background status denied.

BG Denied


Similar Articles