SystemTrigger SystemTrigger SystemTrigger SystemTrigger Class

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

Syntax

Declaration

public sealed class SystemTriggerpublic sealed class SystemTriggerPublic NotInheritable Class SystemTriggerpublic sealed class SystemTrigger

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 summary

Initializes a new instance of a system event trigger.

Properties summary

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

Gets the system event type of a system event trigger.

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, Boolean oneShot)public New(SystemTriggerType triggerType, Boolean oneShot)Public Sub New(triggerType As SystemTriggerType, oneShot As Boolean)public SystemTrigger(SystemTriggerType triggerType, Boolean oneShot)

    Parameters

Properties

  • OneShot
    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 boolpublic bool OneShot { get; }

    Property Value

    • bool
      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 SystemTriggerTypepublic SystemTriggerType TriggerType { get; }

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.ApplicationModel.Background.dll