SystemTrigger SystemTrigger SystemTrigger 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
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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

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();

Constructors

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

Initializes a new instance of a system event trigger.

public SystemTrigger(SystemTriggerType triggerType, Boolean oneShot)public SystemTrigger(SystemTriggerType triggerType, Boolean oneShot)Public Sub New(triggerType As SystemTriggerType, oneShot As Boolean)
Parameters
triggerType
SystemTriggerType SystemTriggerType SystemTriggerType

Specifies the system event type.

oneShot
System.Boolean System.Boolean System.Boolean

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

Attributes

Properties

OneShot OneShot OneShot

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

public bool OneShot { get; }public bool OneShot { get; }Public ReadOnly Property OneShot As bool
Value
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.

Attributes

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
Attributes

See Also