Freigeben über


MaintenanceTrigger Klasse

Definition

Stellt einen Wartungstrigger dar.

public ref class MaintenanceTrigger sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.ApplicationModel.Background.IMaintenanceTriggerFactory, 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 MaintenanceTrigger 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.IMaintenanceTriggerFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class MaintenanceTrigger final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.ApplicationModel.Background.IMaintenanceTriggerFactory), 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 MaintenanceTrigger
[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.IMaintenanceTriggerFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class MaintenanceTrigger
function MaintenanceTrigger(freshnessTime, oneShot)
Public NotInheritable Class MaintenanceTrigger
Vererbung
Object Platform::Object IInspectable MaintenanceTrigger
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 Wartungstrigger 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 every 15 minutes as long as the device is plugged in to AC power.
//
MaintenanceTrigger trigger = new MaintenanceTrigger(15, false);

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

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

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

Hinweise

Hintergrundaufgaben, die einen Wartungstrigger verwenden, werden nur ausgeführt, wenn das System an die Netzstromversorgung angeschlossen ist.

Hinweis

Diese Klasse ist nicht agil, was bedeutet, dass Sie das Threadingmodell und das Marshallverhalten 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

MaintenanceTrigger(UInt32, Boolean)

Initialisiert einen neuen instance eines Wartungstriggers.

Eigenschaften

FreshnessTime

Ruft das Intervall eines Wartungstriggers ab.

OneShot

Ruft ab, ob der Wartungstrigger nur einmal oder jedes Mal verwendet wird, wenn das FreshnessTime-Intervall verstrichen ist.

Gilt für: