BackgroundTaskDeferral.Complete BackgroundTaskDeferral.Complete BackgroundTaskDeferral.Complete BackgroundTaskDeferral.Complete BackgroundTaskDeferral.Complete Method

Definition

Informs the system that an asynchronous operation associated with a background task has finished.

public : void Complete()
void Complete() const;
public void Complete()
Public Sub Complete()
backgroundTaskDeferral.complete();

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.