async.cancel
Shared
Stops an async thread of this resource. A paused thread ends at once; called from the thread itself, it stops right there.
bool async.cancel(any thread)
Parameters
| Name | Type | Description |
|---|---|---|
| thread | any | A thread from async.thread or async.mutex. |
Returns
true if it stopped the thread, false if it is not an async thread of this resource or was already cancelled.
A cancelled thread no longer runs its callback.
Example
local countdown = async.thread(function()
async.wait(10000)
outputDebugString("time is up")
end)
addCommandHandler("stopcountdown", function()
async.cancel(countdown)
end)