System​Trigger System​Trigger System​Trigger System​Trigger Class

Definition

Represents a system event that triggers a background task to run.

public : sealed class SystemTrigger : IBackgroundTrigger, ISystemTriggerpublic sealed class SystemTrigger : IBackgroundTrigger, ISystemTriggerPublic NotInheritable Class SystemTrigger Implements IBackgroundTrigger, ISystemTrigger// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following example shows how to create and register a system trigger with the TimeZoneChanged event.

//
// A friendly task name.
//
String name = "ExampleTaskName";

//
// Must be the same entry point that is specified in the manifest.
//
String taskEntryPoint = "ExampleNamespace.ExampleTaskName";

//
// A system trigger that goes off whenever the time zone is changed, or a change occurs with daylight savings time.
//
IBackgroundTrigger trigger = new SystemTrigger(SystemTriggerType.TimeZoneChange, false);

//
// Builds the background task.
//
BackgroundTaskBuilder builder = new BackgroundTaskBuilder();

builder.Name = name;
builder.TaskEntryPoint = taskEntryPoint;
builder.SetTrigger(trigger);

//
// Registers the background task, and get back a BackgroundTaskRegistration object representing the registered task.
//
BackgroundTaskRegistration task = builder.Register();

Remarks

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).

Constructors

SystemTrigger(SystemTriggerType, Boolean) SystemTrigger(SystemTriggerType, Boolean) SystemTrigger(SystemTriggerType, Boolean) SystemTrigger(SystemTriggerType, Boolean)

Initializes a new instance of a system event trigger.

public : SystemTrigger(SystemTriggerType triggerType, bool oneShot)public SystemTrigger(SystemTriggerType triggerType, Boolean oneShot)Public Sub New(triggerType As SystemTriggerType, oneShot As Boolean)// You can use this method in JavaScript.
Parameters
triggerType
SystemTriggerType SystemTriggerType SystemTriggerType SystemTriggerType

Specifies the system event type.

oneShot
bool Boolean Boolean Boolean

True if the system event trigger will be used once; false if it will be used every time the event occurs.

Properties

OneShot OneShot OneShot OneShot

Gets whether a system event trigger will be used only once.

public : PlatForm::Boolean OneShot { get; }public bool OneShot { get; }Public ReadOnly Property OneShot As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

True if the system event trigger will be used only once; false if it will be used every time the event occurs.

TriggerType TriggerType TriggerType TriggerType

Gets the system event type of a system event trigger.

public : SystemTriggerType TriggerType { get; }public SystemTriggerType TriggerType { get; }Public ReadOnly Property TriggerType As SystemTriggerType// You can use this property in JavaScript.

See Also