YieldTask

Function

Syntax

Ends the current frame and resumes on the next one, like Sync(). Its name reads well inside a task.

YieldTask()

Good to know

  • The parentheses are required: YIELDTASK alone is refused.
  • It yields only where the program can wait: inside the top-level DO … LOOP, in a program with END, or inside a label. It counts as the Sync() that a DO … LOOP requires.
  • Inside a label, put it on its own line with no comment after it. IF … THEN YieldTask() or YieldTask() ' comment compile, but the program cannot start. Put the comment on the line above.
  • It is a point where CANCELTASK stops the task.
  • Inside a FUNCTION it does not yield.

Example

frames = 0counter AS TASKHANDLESTARTTASK counter, CountFramesAWAITTASK counterConsole("frames: " + Str(frames))   ' frames: 5ENDCountFrames:  FOR i = 1 TO 5    frames = frames + 1    ' hand over until the next frame    YieldTask()  NEXTRETURN 0
In the manual : The game loop and tasks

Commands that go with it