Lua:queue

From Cheat Engine
Jump to navigation Jump to search
<> Function

function queue(function, ...) : void

Queues the given function to be called from the main thread.

Any additional arguments are passed to the function when it is called. Unlike synchronize, queue does not wait for the function to finish and does not return a result.

Before freeing the calling thread, make sure to synchronize and call checkSynchronize(). If the thread is freed before the queued function is executed, the queue will be emptied and the queued function will not run. Because of this, using queue is not recommended without setting freeOnTerminate to false.

Function Parameters

Parameter Type Description
function Function The function to call from the main thread.
... Any (optional) Additional arguments that are passed to the function.

Returns

void — This function does not return any value.

Examples

queue(function()
  print("This is executed from the main thread")
end)
local function printMessage(message)
  print(message)
end

queue(function() printMessage("Queued function call") end)

See also

Lua
Script Engine