TaskDone

Function

Syntax

Tells whether a task has returned normally. Polled from the main loop, it lets the game keep drawing while the task works.

TaskDone(<handle>)

Parts

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

Returns

True once the task reached its RETURN. False while it runs, and also when it failed or was cancelled.

Good to know

  • TaskDone() answers true or false, not 1 or 0. Test it bare or with NOT. IF TaskDone(h) = 1 is always false. = TRUE works.
  • Str(TaskDone(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, WorkConsole(Str(TaskDone(job)))   ' falseAWAITTASK jobConsole(Str(TaskDone(job)))   ' trueIF TaskDone(job) THEN Console("done")   ' doneENDWork:  Wait(0.2)RETURN 1
In the manual : The game loop and tasks