webCOMAND

SystemTask::set_canceled()

Attempts to set the state of the System Task to canceling.

Prototype

boolean set_canceled()

Return

Returns TRUE if the System Task state could be changed to canceling.  Otherwise FALSE.

Example

/**
 * Check an HTTP request to see if we should cancel a process,
 * and then gracefully cancel the process if requested.
 */
$request = new \io_comand_web\request();
if($request->get('cancel')) {
    $task_oid = $request->get('toid');
    $repo = comand::repo();
    $task = $repo->get_object_by_oid($task_oid, 'SystemTask');
    if($task && $task->Title == 'My Process') {
        $task->set_canceled();
    }
}

Related

is_canceling(), set_canceling()