ISchedulerJob::CancelTask method

Cancels a task.

Syntax

HRESULT CancelTask(
  [in] ITaskId *taskId
);

Parameters

  • taskId [in]
    An ITaskId interface that identifies the task to cancel.

Return value

If the method succeeds, the return value is S_OK. Otherwise, the return value is an error value. To get a description of the error, access the ISchedulerJob::ErrorMessage property of the job.

Remarks

To cancel a task, the state of the task must be Configuring, Submitted, Queued, or Running. If a task is running when it is canceled, the task is ends and the state of the task changes to Failed. If you cancel a task with a state of Configuring or Queued, the state of the task changes to Canceled.

If you cancel a parametric task, the state of the parametric master task always changes to Canceled, and all of the individual subtasks are canceled. If the subtask is running when you cancel the parametric task, the state of the subtask changes to Failed. If the subtask is in a state other than Running, the state of the subtask changes to Canceled.

To determine the state of a task, access the ISchedulerTask::State property.

You can call the ISchedulerJob::RequeueTask method to queue the task again.

The ISchedulerJob::CancelTask method honors the grace period for the cancellation of the task.

To cancel a task and provide a message to the user that explains the reason you canceled the task in Windows HPC Server 2008 R2, use the ISchedulerJob::CancelTask_2 or ISchedulerJob::CancelTask_3 method. To cancel a task immediately without using the grace period for canceling a task in Windows HPC Server 2008 R2, use the ISchedulerJob::CancelTask_3 method.

Requirements

Product

HPC Pack 2008 R2 Client Utilities, HPC Pack 2008 Client Utilities

Type library

Microsoft.Hpc.Scheduler.tlb

See also

ISchedulerJob

ISchedulerJob::CancelTask_2

ISchedulerJob::CancelTask_3

ISchedulerJob::AddTask

ISchedulerJob::CreateTask

ISchedulerJob::GetTaskIdList

ISchedulerTask