Partager via


SystemCondition Classe

Définition

Représente une condition système qui doit être appliquée pour qu’une tâche en arrière-plan s’exécute.

public ref class SystemCondition sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.ApplicationModel.Background.ISystemConditionFactory, 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 SystemCondition 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.ISystemConditionFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class SystemCondition final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.ApplicationModel.Background.ISystemConditionFactory), 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 SystemCondition
[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.ISystemConditionFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class SystemCondition
function SystemCondition(conditionType)
Public NotInheritable Class SystemCondition
Héritage
Object Platform::Object IInspectable SystemCondition
Attributs
Implémente

Configuration requise pour Windows

Famille d’appareils
Windows 10 (introduit dans 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v1.0)

Exemples

L’exemple suivant développe l’exemple présenté dans SystemTrigger en ajoutant également une condition à la tâche en arrière-plan.

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

//
// A system condition indicating that the background task shouldn't run until the user is present.
//
SystemCondition condition = new SystemCondition(SystemConditionType.UserPresent)

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

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

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

Remarques

Notes

Cette classe n’est pas agile, ce qui signifie que vous devez prendre en compte son modèle de thread et son comportement de marshaling. Pour plus d’informations, consultez Threading and Marshaling (C++/CX) et Utilisation d’objets Windows Runtime dans un environnement multithread (.NET).

Constructeurs

SystemCondition(SystemConditionType)

Initialise une nouvelle instance d’une condition système.

Propriétés

ConditionType

Obtient le type de condition d’une condition système.

S’applique à