Custom Background Tasks
For any type of background task other than playing audio, you have more work to do. You must create a class that implements an interface called IBackgroundTask
, register the task, choose a trigger, and potentially more.
Implementing IBackgroundTask
IBackgroundTask
is a simple interface with a single Run
method. The following dummy implementation does nothing other than show how to report progress and support cancellation, which are two features that can be leveraged by your app when it runs in the foreground:
public sealed class CustomBackgroundTask : IBackgroundTask { bool isCanceled; public void Run(IBackgroundTaskInstance taskInstance) { // Support cancellation taskInstance.Canceled ...
Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.