SystemCondition
SystemCondition
SystemCondition
SystemCondition
Class
Definition
Represents a system condition that must be in effect for a background task to run.
public : sealed class SystemCondition : IBackgroundCondition, ISystemConditionpublic sealed class SystemCondition : IBackgroundCondition, ISystemConditionPublic NotInheritable Class SystemCondition Implements IBackgroundCondition, ISystemCondition// You can use this class in JavaScript.
- Attributes
Windows 10 requirements
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Examples
The following example expands on the example shown in SystemTrigger by also adding a condition to the background task.
//
// 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 = 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();
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).
Constructors
SystemCondition(SystemConditionType) SystemCondition(SystemConditionType) SystemCondition(SystemConditionType) SystemCondition(SystemConditionType)
Initializes a new instance of a system condition.
public : SystemCondition(SystemConditionType conditionType)public SystemCondition(SystemConditionType conditionType)Public Sub New(conditionType As SystemConditionType)// You can use this method in JavaScript.
Parameters
Specifies the condition type.
Properties
ConditionType ConditionType ConditionType ConditionType
Gets the condition type of a system condition.
public : SystemConditionType ConditionType { get; }public SystemConditionType ConditionType { get; }Public ReadOnly Property ConditionType As SystemConditionType// You can use this property in JavaScript.
The condition that must be in effect for the background task to run.