Lua:synchronize
Jump to navigation
Jump to search
Calls the given function from the main thread.
Any additional arguments are passed to the function when it is called. The return value of the given function is returned by synchronize.
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
any — The return value of the given function.
Examples
local result = synchronize(function() return getMainForm().Caption end) print(result)
local function add(a, b) return a + b end local result = synchronize(add, 10, 20) print(result)
function ShowError(message)
if not inMainThread() then
synchronize(function()
self:ShowError(message)
end)
return
end
messageDialog(message, mtError, mbOK)
end
ShowError("Some Error!")