WebUIBackgroundTaskInstanceRuntimeClass WebUIBackgroundTaskInstanceRuntimeClass WebUIBackgroundTaskInstanceRuntimeClass WebUIBackgroundTaskInstanceRuntimeClass Class

Definition

Provides access to an instance of a background task.

Note

A background task must explicitly call the Web Workers close method to terminate itself after the task has completed.

public sealed class WebUIBackgroundTaskInstanceRuntimeClasspublic sealed class WebUIBackgroundTaskInstanceRuntimeClassPublic NotInheritable Class WebUIBackgroundTaskInstanceRuntimeClasspublic sealed class WebUIBackgroundTaskInstanceRuntimeClass
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

To retrieve this object, use the Current property.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX)

.

Properties

InstanceId InstanceId InstanceId InstanceId

Gets the instance ID of the background task instance.

public Guid InstanceId { get; }public Guid InstanceId { get; }Public ReadOnly Property InstanceId As Guidpublic Guid InstanceId { get; }
Value
System.Guid System.Guid System.Guid System.Guid

A unique identifier for the background task instance. This identifier is generated by the system when the instance is created.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Progress Progress Progress Progress

Gets or sets progress status for a background task instance.

public uint Progress { get; set; }public uint Progress { get; set; }Public ReadWrite Property Progress As uintpublic uint Progress { get; set; }
Value
uint uint uint uint

A value defined by the application to indicate the task's progress.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Succeeded Succeeded Succeeded Succeeded

Gets or sets the success value for the background task. The success value is what is returned to the foreground instance of your app in the Completed event.

public bool Succeeded { get; set; }public bool Succeeded { get; set; }Public ReadWrite Property Succeeded As boolpublic bool Succeeded { get; set; }
Value
bool bool bool bool

An app can set this property to false to indicate that the background task has failed. Otherwise this property is always true.

Note

Once the background task sets this property and has therefore completed its work, the task must explicitly call the Web Workers close method to terminate itself.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

SuspendedCount SuspendedCount SuspendedCount SuspendedCount

Gets the number of times resource management policy caused the background task to be suspended.

public uint SuspendedCount { get; }public uint SuspendedCount { get; }Public ReadOnly Property SuspendedCount As uintpublic uint SuspendedCount { get; }
Value
uint uint uint uint

The number of times the background task has been suspended.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Task Task Task Task

Gets access to the registered background task for this background task instance.

public BackgroundTaskRegistration Task { get; }public BackgroundTaskRegistration Task { get; }Public ReadOnly Property Task As BackgroundTaskRegistrationpublic BackgroundTaskRegistration Task { get; }
Value
BackgroundTaskRegistration BackgroundTaskRegistration BackgroundTaskRegistration BackgroundTaskRegistration

An interface that provides access to the registered background task.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

TriggerDetails TriggerDetails TriggerDetails TriggerDetails

Gets additional information associated with a background task instance.

public object TriggerDetails { get; }public object TriggerDetails { get; }Public ReadOnly Property TriggerDetails As objectpublic object TriggerDetails { get; }
Value
object object object object

Represents additional information for the background task. If the background task is triggered by a mobile network operator notification, this property is an instance of a NetworkOperatorNotificationEventDetails class. If the background task is triggered by a system event or time event, this property is not used.

Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Methods

GetDeferral() GetDeferral() GetDeferral() GetDeferral()

Informs the system that the background task might continue to perform work after the Run(IBackgroundTaskInstance) method returns. This method is not applicable to JavaScript background tasks.

public BackgroundTaskDeferral GetDeferral()public BackgroundTaskDeferral GetDeferral()Public Function GetDeferral() As BackgroundTaskDeferralpublic BackgroundTaskDeferral GetDeferral()
Returns
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

This method is not applicable for background tasks written in JavaScript. JavaScript background tasks use the Web Workers close method to finish the task after all asynchronous operations have completed.

Events

Canceled Canceled Canceled Canceled

Attaches a cancellation event handler to the background task instance.

public event BackgroundTaskCanceledEventHandler Canceledpublic event BackgroundTaskCanceledEventHandler CanceledPublic Event Canceledpublic event BackgroundTaskCanceledEventHandler Canceled
Attributes
Additional features and requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

In most cases, JavaScript background tasks continue to run until the Web Workers close method is called. The system shuts down a background task only when all apps are being closed, for example user log off or system shut down. In that case, Windows fires the canceled event, enabling the background task to complete any final activity before it is closed.