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:
YIELDTASKalone is refused. - It yields only where the program can wait: inside the top-level
DO … LOOP, in a program withEND, or inside a label. It counts as the Sync() that aDO … LOOPrequires. - Inside a label, put it on its own line with no comment after it.
IF … THEN YieldTask()orYieldTask() ' commentcompile, but the program cannot start. Put the comment on the line above. - It is a point where
CANCELTASKstops the task. - Inside a
FUNCTIONit 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 0In the manual : The game loop and tasks