SystemCondition class

Applies to Windows and Windows Phone

Represents a system condition that must be in effect for a background task to run.

Syntax


var systemCondition = new Windows.ApplicationModel.Background.SystemCondition();

Attributes

[MarshalingBehavior(Standard)]
[Threading(MTA)]
[Version(0x06020000)]

Members

The SystemCondition class has these types of members:

Constructors

The SystemCondition class has these constructors.

ConstructorDescription
SystemCondition Initializes a new instance of a system condition.

 

Properties

The SystemCondition class has these properties.

PropertyAccess typeDescription

ConditionType

Read-onlyGets the condition type of a system condition.

 

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).

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

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.winmd

 

 

Show:
© 2014 Microsoft