async(task, ...)
Throws an asynchronous task.
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 object instance.Example
-- Throws an asynchronous Task which will count from 5 to 10
async (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).after = function(result)
print(result)
end
-- wait for all task to terminate
waitall()