IBackgroundTaskInstance
IBackgroundTaskInstance
IBackgroundTaskInstance
IBackgroundTaskInstance
Interface
Definition
Provides access to a background task instance.
public : interface IBackgroundTaskInstancepublic interface IBackgroundTaskInstancePublic Interface IBackgroundTaskInstance// You can use this interface in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Properties
InstanceId InstanceId InstanceId InstanceId
Gets the instance ID of the background task instance.
public : PlatForm::Guid InstanceId { get; }public Guid InstanceId { get; }Public ReadOnly Property InstanceId As Guid// You can use this property in JavaScript.
- Value
- PlatForm::Guid Guid Guid Guid
A unique identifier for the background task instance. This identifier is generated by the system when the instance is created.
Progress Progress Progress Progress
Gets or sets progress status for a background task instance.
public : unsigned int Progress { get; set; }public uint Progress { get; set; }Public ReadWrite Property Progress As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
A value defined by the application to indicate the task's progress.
SuspendedCount SuspendedCount SuspendedCount SuspendedCount
Gets the number of times resource management policy caused the background task to be suspended.
public : unsigned int SuspendedCount { get; }public uint SuspendedCount { get; }Public ReadOnly Property SuspendedCount As uint// You can use this property in JavaScript.
- Value
- unsigned int uint uint uint
The number of times the background task has been suspended.
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 BackgroundTaskRegistration// You can use this property in JavaScript.
- Value
- BackgroundTaskRegistration BackgroundTaskRegistration BackgroundTaskRegistration BackgroundTaskRegistration
An interface that provides access to the registered background task.
TriggerDetails TriggerDetails TriggerDetails TriggerDetails
Gets additional information associated with a background task instance.
public : PlatForm::Object TriggerDetails { get; }public object TriggerDetails { get; }Public ReadOnly Property TriggerDetails As object// You can use this property in JavaScript.
- Value
- PlatForm::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.
Methods
GetDeferral() GetDeferral() GetDeferral() GetDeferral()
Informs the system that the background task might continue to perform work after the IBackgroundTask.Run method returns.
public : BackgroundTaskDeferral GetDeferral()public BackgroundTaskDeferral GetDeferral()Public Function GetDeferral() As BackgroundTaskDeferral// You can use this method in JavaScript.
A background task deferral.
Remarks
If a background task uses an asynchronous operation, it is possible for the Run method to return before the background task has completed its work. As soon as the Run method returns, the system might suspend or terminate the background task host process, which could prevent completion of asynchronous operations started by the background task.
To keep the host process from being suspended or terminated while the background task is running, use the GetDeferral method to get a background task deferral for each asynchronous operation initiated. Then, when the asynchronous operation is finished, call the BackgroundTaskDeferral.Complete method.
Ensure that you complete all background task deferrals. Most background tasks have a timeout after which the app will be suspended or terminated regardless of whether there are any pending deferrals. However, leaving outstanding background task deferrals interferes with the system's ability to manage process lifetimes in a timely way.
Events
Canceled Canceled Canceled Canceled
Attaches a cancellation event handler to the background task instance.
For Windows Phone Store app, if the device becomes low on memory, background tasks may be terminated without any warning and without raising the OnCanceled event. This helps to ensure the user experience of the app in the foreground. Your background task should be designed to handle this scenario.
public : abstract event BackgroundTaskCanceledEventHandler Canceledpublic abstract event BackgroundTaskCanceledEventHandler CanceledPublic MustInherit Event Canceled// You can use this event in JavaScript.