Represents an event that an application can trigger to initiate a fixed-length, long-running operation (content transfer, sync) with a device.
Windows 8.1 enables you to develop Windows Store apps for your peripheral devices that communicate over USB, HID, and Bluetooth. For example, a user might need to sync content on a PC to or from the device, or perform a long-running update to the device itself like settings or firmware updates. Windows 8.1 provides two background tasks and corresponding APIs that allow your device to sync and update in the background: DeviceServicingTrigger and DeviceUseTrigger. This topic provides API reference information for DeviceUseTrigger - for info on using this trigger in the context of a device app, see Device sync and update for Windows Store device apps.
The DeviceUseTrigger background task allows your Windows Store app that interacts with your peripheral device to perform a long running sync from the user's PC to or from the device while your app is suspended, for example syncing content from your device to the PC. Syncing your device in the background requires that your user has approved background syncing by your app. Your device must also be connected or paired with the PC, with active I/O, and is allowed a maximum of 10 minutes of background activity.
- More detail on the policy requirements of the DeviceUseTrigger background task can be found in the Remarks section of this page.
- For info about using the DeviceUseTrigger see Device sync and update for Windows Store device apps.
- For info on DeviceServicingTrigger, see the DeviceServicingTrigger reference topic.
var deviceUseTrigger = new Windows.ApplicationModel.Background.DeviceUseTrigger();
The DeviceUseTrigger class has these types of members:
The DeviceUseTrigger class has these constructors.
|DeviceUseTrigger||Constructor for DeviceUseTrigger. Takes no parameters.|
The DeviceUseTrigger class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
|RequestAsync(String)||Triggers the device background task (sync or content transfer) and returns a DeviceTriggerResult indicating success or failure of the trigger request. Takes the DeviceInformation.ID of the device the background task will sync with.|
|RequestAsync(String, String)||Triggers the device background task (sync or content transfer) and returns a DeviceTriggerResult indicating success or failure of the trigger request. Takes the DeviceInformation.ID of the device the background task will sync with, and an optional app-specific string passed to the background task identifying which device operation to perform.|
The DeviceInformation.Id passed to the RequestAsync method must match the device that will perform the background operation. The DeviceInformation.Id is used by Windows to ensure that policy requirements are met.
Certain policies are enforced by Windows to ensure user consent when updating their peripheral devices. Additional polices are enforced to preserve user battery life when syncing and updating peripheral devices. The DeviceUseTrigger background task is subject to the following policies:
- The DeviceUseTrigger background task requires a one-time user consent allowing your app to sync in the background. This consent is stored on a per-app and per-device basis, just like user consent for your app to access a device using the USB, HID and Bluetooth APIs.
- Your device must be connected or paired with the PC and available when requesting the trigger.
- Your app is allowed a maximum of 10 minutes (wall clock) of background activity for background sync with DeviceUseTrigger.
- Your app can only run one DeviceUseTrigger background task at a time. Attempting to create a second DeviceUseTrigger will raise an exception.
- Your app is not allowed to trigger DeviceUseTrigger background tasks while your app is not in the foreground.
- DeviceUseTrigger background tasks may be canceled by Windows when these policy requirements are no longer met, including a maximum amount of wall clock background time.
For detailed information about the policy checks enforced by Windows for the DeviceUseTrigger background task, see Device sync and update for Windows Store device apps.
Minimum supported client
|Windows 8.1 [Windows Store apps only]|
Minimum supported server
|Windows Server 2012 R2 [Windows Store apps only]|