BackgroundTaskBuilder BackgroundTaskBuilder BackgroundTaskBuilder BackgroundTaskBuilder BackgroundTaskBuilder Class


Represents a background task to register with the system.

public : sealed class BackgroundTaskBuilder : IBackgroundTaskBuilder, IBackgroundTaskBuilder2, IBackgroundTaskBuilder3, IBackgroundTaskBuilder4
struct winrt::Windows::ApplicationModel::Background::BackgroundTaskBuilder : IBackgroundTaskBuilder, IBackgroundTaskBuilder2, IBackgroundTaskBuilder3, IBackgroundTaskBuilder4
public sealed class BackgroundTaskBuilder : IBackgroundTaskBuilder, IBackgroundTaskBuilder2, IBackgroundTaskBuilder3, IBackgroundTaskBuilder4
Public NotInheritable Class BackgroundTaskBuilder Implements IBackgroundTaskBuilder, IBackgroundTaskBuilder2, IBackgroundTaskBuilder3, IBackgroundTaskBuilder4
var backgroundTaskBuilder = new backgroundTaskBuilder();
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)



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) and Using Windows Runtime objects in a multithreaded environment (.NET).

If your background task requires network connectivity, be aware of the following:

** Network related triggers**

  • Use a SocketActivityTrigger to activate the background task when a packet is received and you need to perform a short-lived task. After performing the task, the background task should terminate to save power.
  • Use a ControlChannelTrigger to activate the background task when a packet is received and you need to perform a long-lived task.

** Network related conditions and flags**

  • Add the InternetAvailable condition (BackgroundTaskBuilder.AddCondition ) to your background task to delay triggering the background task until the network stack is running. This condition saves power because the background task won't execute until network access is available. This condition does not provide real-time activation.

Regardless of the trigger you use, set IsNetworkRequested on your background task to ensure that the network stays up while the background task runs. This tells the background task infrastructure to keep the network up while the task is executing, even if the device has entered Connected Standby mode. If your background task does not use IsNetworkRequested, then your background task will not be able to access the network when in Connected Standby mode (for example, when a phone's screen is turned off.)


BackgroundTaskBuilder() BackgroundTaskBuilder() BackgroundTaskBuilder() BackgroundTaskBuilder() BackgroundTaskBuilder()

Creates an instance of the BackgroundTaskBuilder class.


CancelOnConditionLoss CancelOnConditionLoss CancelOnConditionLoss CancelOnConditionLoss CancelOnConditionLoss

Indicates whether the background task will be canceled if at least one of its required conditions is no longer met.

IsNetworkRequested IsNetworkRequested IsNetworkRequested IsNetworkRequested IsNetworkRequested

Indicates whether to keep the network up while running the background task.

Name Name Name Name Name

Gets or sets the name of a background task.

TaskEntryPoint TaskEntryPoint TaskEntryPoint TaskEntryPoint TaskEntryPoint

Gets or sets the class that performs the work of a background task.

TaskGroup TaskGroup TaskGroup TaskGroup TaskGroup

Gets and sets the group identifier.


AddCondition(IBackgroundCondition) AddCondition(IBackgroundCondition) AddCondition(IBackgroundCondition) AddCondition(IBackgroundCondition) AddCondition(IBackgroundCondition)

Adds a condition to a background task.

Register() Register() Register() Register() Register()

Registers a background task with the system.

SetTrigger(IBackgroundTrigger) SetTrigger(IBackgroundTrigger) SetTrigger(IBackgroundTrigger) SetTrigger(IBackgroundTrigger) SetTrigger(IBackgroundTrigger)

Sets the event trigger for a background task.