BackgroundTaskCompletedEventArgs BackgroundTaskCompletedEventArgs BackgroundTaskCompletedEventArgs BackgroundTaskCompletedEventArgs BackgroundTaskCompletedEventArgs Class


Represents completion information for a task at the time a completion notification is sent.

public : sealed class BackgroundTaskCompletedEventArgs : IBackgroundTaskCompletedEventArgs
struct winrt::Windows::ApplicationModel::Background::BackgroundTaskCompletedEventArgs : IBackgroundTaskCompletedEventArgs
public sealed class BackgroundTaskCompletedEventArgs : IBackgroundTaskCompletedEventArgs
Public NotInheritable Class BackgroundTaskCompletedEventArgs Implements IBackgroundTaskCompletedEventArgs
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


The following example shows how to use the BackgroundTaskCompletedEventArgs class with a BackgroundTaskCompletedEventHandler delegate to monitor background task completion while the app is in the foreground. Note that this depends on the background task to report status via LocalSettings.

private async void OnCompleted(IBackgroundTaskRegistration task,
                               BackgroundTaskCompletedEventArgs args)
    var settings = ApplicationData.Current.LocalSettings;
    var key = task.TaskId.ToString();
    string status = settings.Values[key].ToString();

    // UI element updates should be done asynchronously.
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
    () =>
        ExampleProgressElement.Text = "Task completed with status: " + status;


The system generates this class and passes it as an argument to the application's BackgroundTaskCompletedEventHandler handler.


InstanceId InstanceId InstanceId InstanceId InstanceId

Gets the identifier of the background task instance for this completion status notification.

public : Platform::Guid InstanceId { get; }
Guid InstanceId();
public Guid InstanceId { get; }
Public ReadOnly Property InstanceId As Guid
var guid = backgroundTaskCompletedEventArgs.instanceId;
Guid Guid Guid

A unique identifier generated by the system when it creates the background task instance.


CheckResult() CheckResult() CheckResult() CheckResult() CheckResult()

Throws an exception if the background task completed event has reported an error.

public : void CheckResult()
void CheckResult() const;
public void CheckResult()
Public Function CheckResult() As void


This method should be called from within a try block. If the background task completed event reported an error, it will be caught as an exception in the subsequent catch clause.