BackgroundTaskBuilder.SetTrigger(IBackgroundTrigger) Method

Definition

Sets the event trigger for a background task.

public:
 virtual void SetTrigger(IBackgroundTrigger ^ trigger) = SetTrigger;
void SetTrigger(IBackgroundTrigger const & trigger);
public void SetTrigger(IBackgroundTrigger trigger);
function setTrigger(trigger)
Public Sub SetTrigger (trigger As IBackgroundTrigger)

Parameters

trigger
IBackgroundTrigger

An instance of an event trigger object such as a SystemTrigger, TimeTrigger, or NetworkOperatorNotificationTrigger.

Remarks

In addition to specifying the type of event trigger for a background task, an application must also enable background tasks that use the event trigger type in the <Extensions><Extension><BackgroundTasks> section of its manifest. Valid types include the following:

  • <Task Type="audio"/>
  • <Task Type="timer"/>
  • <Task Type="systemEvent"/>
  • <Task Type="pushNotification"/>
  • <Task Type="realTimeCommunication"/>

If the background task type is not specified or specified incorrectly in the manifest, calls that attempt to use that kind of background task will fail.

List of triggers:

Trigger Description
ActivitySensorTrigger Used when your application needs to respond to the activity sensor.
AppBroadcastTrigger Trigger a background task to run when an application starts gameplay broadcasting.
ApplicationTrigger Trigger a background tasks from within your application.
AppointmentStoreNotificationTrigger Trigger to launch a background task for processing changes to the appointment store.
BluetoothLEAdvertisementPublisherTrigger Represents a trigger that is registered to advertise a Bluetooth LE advertisement in the background.
CachedFileUpdaterTrigger Trigger a background task to enable the Cached File Updater contract.
ChatMessageNotificationTrigger Represents a trigger that is activated when there is a notification for a text message.
ChatMessageReceivedNotificationTrigger Represents a trigger that launches a background task that handles any incoming message that might need to be filtered according to its content.
CommunicaionBlockingAppSetAsActiveTrigger Represents a trigger to activate a communication blocking application when it is selected as the preferred blocking app.
ContactStoreNotificationTrigger Represents a trigger that launches a background task for processing changes to the contacts store.
ContentPrefetchTrigger Provides the ability to run custom handlers when prefetching web resources.
CustomSystemEventTrigger A custom system trigger that you can define .
DeviceConnectionChangeTrigger Represents an event that an application can trigger to initiate a long-running update (firmware or settings) of a device.
DeviceManufacturerNotificationTrigger Represents an event that an application can trigger to initiate a long-running update (firmware or settings) of a device.
DeviceUseTrigger Represents an event that a Windows Runtime app can trigger to initiate a long-running operation with a device or sensor.
EmailStoreNotificationTrigger Represents a trigger that enables notification of changes to the email store.
GattCharacteristicNotificationTrigger Represents a trigger that launches a background task when an incoming change notification is received for a Bluetooth LE GATT characteristic.
GattServiceProviderTrigger Constructs a Generic Attributes (GATT) service that can be persisted in the background.
GeovisitTrigger Represents an event that triggers a Visits-related background task.
LocationTrigger Represents a location event that triggers a background task. This is used for Geofencing.
MaintenanceTrigger Represents a maintenance trigger which runs only when the system is connected to AC power.
MediaProcessingTrigger Represents a trigger that launches a background task for performing media processing.
MobileBroadbandDeviceServiceNotificationTrigger Represents a trigger that activates when the network sends SIM tool commands. Apps receiving this notification then process the SIM tool commands.
MobileBroadbandPcoDataChangeTrigger Represents a cellular protocol configuration option change event that triggers a background task to run.
MobileBroadbandPinLockStateChangeTrigger Represents a trigger that indicates when the SIM PIN lock state has changed.
MobileBroadbandRadioStateChangeTrigger Represents a trigger that indicates when mobile broadband radio state has changed. For example, this trigger activates when a mobile device transitions to or from airplane mode.
MobileBroadbandRegistrationStateChangeTrigger Represents a trigger that indicates when mobile broadband registration state has changed. For example, this trigger activates when a mobile device transitions to or from Roaming.
NetworkOperatorDataUsageTrigger Represents a trigger that launches a background task when the local data counters estimate that usage (bytes sent and received) on the mobile broadband interface has changed by an actionable threshold.
NetworkOperatorHotspotAuthenticationTrigger Represents a mobile network operator hotspot authentication trigger.
NetworkOperatorNotificationTrigger Represents a mobile network operator notification trigger.
PaymentAppCanMakePaymentTrigger Represents a PaymentAppCanMakePayment trigger.
PhoneTrigger Represents a phone event that triggers a background task.
PushNotificationTrigger Represents a trigger that invokes a background work item on the app in response to the receipt of a raw notification.
RcsEndUserMessageAvailableTrigger Represents a trigger that launches a background task when a new Rich Communication Services (RCS) message is available.
RfcommConnectionTrigger Represents a trigger that launches a background task when an RFCOMM inbound or outbound connections are established.
SecondaryAuthenticationFactorAuthenticationTrigger Represents a trigger that launches a background task on behalf of a companion device.
SensorDataThresholdTrigger Represents a trigger that responds when a threshold limit for a sensor is crossed.
SmartCardTrigger Represents an event triggered by a smart card.
SmsMessageReceivedTrigger Represents a trigger that is raised when an SMS message has arrived.
SocketActivityTrigger Represents a trigger that launches a background task for handling socket activity.
StorageLibraryChangeTrackerTrigger Represents a file change within a StorageFolder that triggers a background task to run.
StorageLibraryContentChangedTrigger Creates a trigger that will fire when a file is changed in a specified library.
SystemCondition Represents a system condition that must be in effect for a background task to run.
SystemTrigger Represents a system event that triggers a background task to run.
TetheringEntitlementCheckTrigger Represents a tethering event that triggers a background task to run.
TimeTrigger Represents a time event that triggers a background task to run.
ToastNotificationActionTrigger Represents an event that causes a background task to run when the user performs an action on an interactive toast notification.
ToastNotificationHistoryChangedTrigger Represents an event that causes a background task to run when the history of toast notifications for the app is cleared, when one or more toast notifications are added to or removed from the notification history for the app, or when one or more toast notifications for the app expire and are removed from the notification history.
UserNotificationChangedTrigger Represents a trigger that fires when a UserNotification is added or removed.

Applies to