Export (0) Print
Expand All

Starting a Task Example

To start a task, call the Run method of the ITask interface. Run is an asynchronous method that attempts to execute the task and returns as soon as the task has started. The Task Scheduler service must be running for this method to succeed.

The following procedure describes how to start a task.

Aa382529.wedge(en-us,VS.85).gifTo start a task

  1. Call CoInitialize to initialize the COM library and CoCreateInstance to get a Task Scheduler object. (This example assumes that the Task Scheduler service is running.)
  2. Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that this example gets the "Test Task" task.)
  3. Call Run to start the task. Note that this method is inherited by the ITask interface.
  4. Continue processing as needed.
  5. Call ITask::Release to free resources and CoUninitialize to uninitialize COM. This example calls Release to free the pointer to the ITask interface. (Note that Release is an IUnknown method inherited by ITask.)
For a code example ofSee
Running an existing task C/C++ Code Example: Starting a Task

 

Related topics

Task Scheduler 1.0 Examples

 

 

Community Additions

ADD
Show:
© 2014 Microsoft