Condividi tramite


SystemTrigger Classe

Definizione

Rappresenta un evento di sistema che attiva un'attività in background da eseguire.

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
Ereditarietà
Object Platform::Object IInspectable SystemTrigger
Attributi
Implementazioni

Requisiti Windows

Famiglia di dispositivi
Windows 10 (è stato introdotto in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v1.0)

Esempio

Nell'esempio seguente viene illustrato come creare e registrare un trigger di sistema con l'evento TimeZoneChanged .

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

Commenti

Nota

Questa classe non è agile, il che significa che è necessario considerare il relativo modello di threading e il comportamento di marshalling. Per altre informazioni, vedere Threading e marshalling (C++/CX) eUso di oggetti Windows Runtime in un ambiente multithreaded (.NET).

Costruttori

SystemTrigger(SystemTriggerType, Boolean)

Inizializza una nuova istanza di un trigger di eventi di sistema.

Proprietà

OneShot

Ottiene se un trigger di eventi di sistema verrà usato una sola volta.

TriggerType

Ottiene il tipo di evento di sistema di un trigger di eventi di sistema.

Si applica a

Vedi anche