await(task...)function

Wait for the task to terminate, suspending execution and allowing other tasks to run during this time.

Parameters

task...

A function or a Task object instance to wait for.If a function is supplied, a new task instance is transparently created and started.

Other provided optional arguments are used as function arguments when the Task is started.

Return value

This function returns the Task return values.

Example

-- Counts from 5 to 10 print (await (function (from, to) local i = from while i <= to do sleep(500) print(i) i = i +1 end -- The Task will return the string "Done !" return "Done !" end, 5, 10))