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.
To start a task
- 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.)
- Call ITaskScheduler::Activate to get the ITask interface of the task object. (Note that this example gets the "Test Task" task.)
- Call Run to start the task. Note that this method is inherited by the ITask interface.
- Continue processing as needed.
- 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 of | See |
---|---|
Running an existing task | C/C++ Code Example: Starting a Task |
Related topics