TaskCancelled

Function

Syntax

Tells whether CANCELTASK was called on a task that was still running.

TaskCancelled(<handle>)

Parts

<handle>A task handle: a variable filled by STARTTASK.

Returns

True as soon as CANCELTASK was called, even before the task reaches its next yield. False if the task had already ended when it was cancelled.

Good to know

  • TaskCancelled() answers true or false, not 1 or 0. Test it bare or with NOT. IF TaskCancelled(h) = 1 is always false. = TRUE works.
  • Str(TaskCancelled(h)) gives true or false.
  • A handle that never received a task (still NULL) stops the program with BASIC value is not a task handle.

Example

job AS TASKHANDLESTARTTASK job, PatrolWait(0.1)CANCELTASK jobIF TaskCancelled(job) THEN Console("cancel requested")   ' cancel requestedAWAITTASK jobIF NOT TaskDone(job) THEN Console("never finished")      ' never finishedENDPatrol:  Wait(10)RETURN 1
In the manual : The game loop and tasks