MaintenanceTrigger class

0 out of 5 rated this helpful - Rate this topic

Represents a maintenance trigger.

Syntax


var maintenanceTrigger = new Windows.ApplicationModel.Background.MaintenanceTrigger();

Attributes

ActivatableAttribute(Windows.ApplicationModel.Background.IMaintenanceTriggerFactory, NTDDI_WIN8)
MarshalingBehaviorAttribute(Standard)
ThreadingAttribute(MTA)
VersionAttribute(NTDDI_WIN8)

Members

The MaintenanceTrigger class has these types of members:

Constructors

The MaintenanceTrigger class has these constructors.

ConstructorDescription
MaintenanceTrigger Initializes a new instance of a maintenance trigger.

 

Methods

The MaintenanceTrigger class inherits methods from the Object class (C#/VB/C++).

Properties

The MaintenanceTrigger class has these properties.

PropertyAccess typeDescription

FreshnessTime

Read-onlyGets the interval of a maintenance trigger.

OneShot

Read-onlyGets whether the maintenance trigger is used only once or each time the FreshnessTime interval elapses.

 

Remarks

Background tasks that use a maintenance trigger run only when the system is connected to AC power.

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 shows how to create and register a maintenance trigger.


//
// A friendly task name.
//
var name = "ExampleTaskName";

//
// Must be the same entry point that is specified in the manifest.
//
var taskEntryPoint = "ExampleNamespace.ExampleTaskName";

//
// A system trigger that goes off every 15 minutes as long as the device is plugged in to AC power.
//
var trigger = new Windows.ApplicationModel.Background.MaintenanceTrigger(15, false);

//
// Build the background task.
//
var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder();

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

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

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Namespace

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

Metadata

Windows.winmd

 

 

Build date: 12/4/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.