BackgroundTaskProgressEventArgs 类

定义

表示发送进度更新通知时任务的进度信息。

public ref class BackgroundTaskProgressEventArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BackgroundTaskProgressEventArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class BackgroundTaskProgressEventArgs
Public NotInheritable Class BackgroundTaskProgressEventArgs
继承
Object Platform::Object IInspectable BackgroundTaskProgressEventArgs
属性

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例演示如何将 BackgroundTaskProgressEventArgs 类与 BackgroundTaskProgressEventHandler 委托一起使用,以便在应用位于前台时显示后台任务进度。

private async void OnProgress(IBackgroundTaskRegistration task, BackgroundTaskProgressEventArgs args)
{
    //
    // UI element updates should be done asynchronously.
    //
    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
    () =>
    {
        ExampleProgressElement.Text = "Progress is at " args.Progress + "%.";
    });
}

注解

系统生成此类,并将其作为参数传递给应用程序的 BackgroundTaskProgressEventHandler 处理程序。

属性

InstanceId

获取此进度状态通知的后台任务实例的标识符。

Progress

获取后台任务实例的进度状态。

适用于