| -api-id | T:Windows.ApplicationModel.Background.BackgroundTaskBuilder |
|---|---|
| -api-type | winrt class |
Represents a background task to register with the system.
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) 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.)
| Windows version | SDK version | Value added |
|---|---|---|
| 1703 | 15063 | TaskGroup |
| 2004 | 19041 | SetTaskEntryPointClsid |