SystemTrigger SystemTrigger SystemTrigger SystemTrigger SystemTrigger Class

Definition

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

public : sealed class SystemTrigger : IBackgroundTrigger, ISystemTrigger
struct winrt::Windows::ApplicationModel::Background::SystemTrigger : IBackgroundTrigger, ISystemTrigger
public sealed class SystemTrigger : IBackgroundTrigger, ISystemTrigger
Public NotInheritable Class SystemTrigger Implements IBackgroundTrigger, ISystemTrigger
var systemTrigger = new systemTrigger(triggerType, oneShot);
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) SystemTrigger(SystemTriggerType, Boolean)

Initializes a new instance of a system event trigger.

Properties

OneShot OneShot OneShot OneShot OneShot

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

TriggerType TriggerType TriggerType TriggerType TriggerType

Gets the system event type of a system event trigger.

See also