Freigeben über


SystemTrigger Klasse

Definition

Stellt ein Systemereignis dar, das die Ausführung einer Hintergrundaufgabe auslöst.

public ref class SystemTrigger sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.ApplicationModel.Background.ISystemTriggerFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
class SystemTrigger final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
/// [Windows.Foundation.Metadata.Activatable(Windows.ApplicationModel.Background.ISystemTriggerFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class SystemTrigger final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.ApplicationModel.Background.ISystemTriggerFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
public sealed class SystemTrigger
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Standard)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.ApplicationModel.Background.ISystemTriggerFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class SystemTrigger
function SystemTrigger(triggerType, oneShot)
Public NotInheritable Class SystemTrigger
Vererbung
Object Platform::Object IInspectable SystemTrigger
Attribute
Implementiert

Windows-Anforderungen

Gerätefamilie
Windows 10 (eingeführt in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v1.0)

Beispiele

Das folgende Beispiel zeigt, wie Sie einen Systemtrigger mit dem TimeZoneChanged-Ereignis erstellen und registrieren.

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

Hinweise

Hinweis

Diese Klasse ist nicht agil, was bedeutet, dass Sie das Threadingmodell und das Marshallingverhalten berücksichtigen müssen. Weitere Informationen finden Sie unter Threading and Marshaling (C++/CX) und Using Windows-Runtime objects in a multithreaded environment (.NET).

Konstruktoren

SystemTrigger(SystemTriggerType, Boolean)

Initialisiert einen neuen instance eines Systemereignistriggers.

Eigenschaften

OneShot

Ruft ab, ob ein Systemereignistrigger nur einmal verwendet wird.

TriggerType

Ruft den Systemereignistyp eines Systemereignistriggers ab.

Gilt für:

Weitere Informationen