M MY Multiplayer: Wiki
Side
Kind

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

NameTypeDescription
threadanyA 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)

See also