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 withNOT.IF TaskCancelled(h) = 1is always false.= TRUEworks.- Str(TaskCancelled(h)) gives
trueorfalse. - A handle that never received a task (still
NULL) stops the program withBASIC 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 1In the manual : The game loop and tasks