task.defer
Queues a function on the executor scheduler.
Syntax
Signature
task.defer(Callback: function, ...: any) -> threadAliases
task.spawn
Parameters
| Parameter | Type | Description |
|---|---|---|
Callback | function | Function to run on the executor scheduler. |
... | ...any | Arguments passed to Callback. |
Returns
| Type | Description |
|---|---|
thread | New coroutine queued for execution. |
Notes
task.spawn and task.defer currently use the same queue. Only functions are accepted. The returned coroutine has not run when this call returns.
Example
Luau
local Job = task.spawn(function(Name)
print("Started:", Name)
task.wait(0.5)
print("Finished:", Name)
end, "Example")
print("Queued coroutine:", Job)
-- task.defer uses the same queue in this executor.