-
Notifications
You must be signed in to change notification settings - Fork 197
Classes Overview
Each Release contains a full help file (TaskSchedulerHelp.zip) which is an MSHelp file that documents every class in detail.
The TaskService
class represents the machine specific instance of the system task scheduler. It provides access to information about the service, access folders (2.0 only), and can quickly add or retrieve a task. If you only need to use the library for very intermittent periods, wrap the TaskService
instantiation in a using
statement to easily disconnect at the end of your use. However, if you plan on using the connection to the Task Scheduler repeatedly, use an assembly level field to store the TaskService
instance as connecting and disconnecting is an expensive operation. If you only need to use a local instance that runs in the current user's context, use the static property TaskService.Instance
.
Tasks are accessed and can be enumerated through a TaskFolder
. For systems supporting only the 1.0 library, there is only the root folder. The 2.0 library supports a hierarchal structure similar to a file system. The Tasks
property exposes a TaskCollection
instance which can enumerate tasks and provides an indexer which allows access to individual tasks by name. The TaskCollection
class also has methods that allow for the creation/registration and deletion of tasks and subfolders by name.
A task is represented by a Task
instance. The Task class provides information about tasks state and history and exposes the task's TaskDefinition
through the Definition
property.
A TaskDefinition
exposes all of the properties of a task which allow you to define how and what will run when the task is triggered. A task must have at least one action defined.
Each task has a list of triggers that determine when the task will be run. These are accessed through the Triggers
property of a task definition which exposes a TriggerCollection
instance. TriggerCollection
provides an indexer which allows access to individual triggers by their position in the list. The TriggerCollection
class also has methods that allow for the addition and removal of triggers. TriggerCollection
implements the IList
interface so you can also enumerate all tasks using the foreach
construct.
The Trigger
class is an abstract class that forms the foundation of the different types of triggers that can be specified for a task. There are 10 different specializations that provide different ways to specify the time a task will run. Not all specializations work with the 1.0 library. See the help file for details about each of the trigger classes. The Trigger Documentation has some examples of how to setup each kind of trigger.
The Action
class is an abstract class that is the foundation for four different actions. On 1.0, only the ExecAction
specialization is available unless the PowerShellConversion
option is enabled (see Action Documentation for more information). These actions determine what the service will do when a trigger is fired. The Action Documentation has some examples of how to setup each kind of action.