Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

BackgroundTaskCompletedEventArgs class

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

Syntax


/* For information about creating or accessing this object, see Remarks. */

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

Members

The BackgroundTaskCompletedEventArgs class has these types of members:

Methods

The BackgroundTaskCompletedEventArgs class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

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

 

Properties

The BackgroundTaskCompletedEventArgs class has these properties.

PropertyAccess typeDescription

InstanceId

Read-onlyGets the identifier of the background task instance for this completion status notification.

 

Remarks

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

Examples

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;
    });
}

Requirements (device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (operating system)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.winmd

See also

Object

 

 

Show:
© 2015 Microsoft