SystemCondition 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, ISystemCondition
struct winrt::Windows::ApplicationModel::Background::SystemCondition : IBackgroundCondition, ISystemCondition
public sealed class SystemCondition : IBackgroundCondition, ISystemCondition
Public NotInheritable Class SystemCondition Implements IBackgroundCondition, ISystemCondition
var systemCondition = new systemCondition(conditionType);
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) SystemCondition(SystemConditionType)

Initializes a new instance of a system condition.

Properties

ConditionType ConditionType ConditionType ConditionType ConditionType

Gets the condition type of a system condition.