Difference between revisions of "Lua:inMainThread"

From Cheat Engine
Jump to navigation Jump to search
m (Added related function template.)
 
(One intermediate revision by the same user not shown)
Line 14: Line 14:
  
 
===Examples===
 
===Examples===
<pre>
+
<syntaxhighlight lang="lua" line>
 
if inMainThread() then
 
if inMainThread() then
 
   print("Running in the main thread")
 
   print("Running in the main thread")
Line 20: Line 20:
 
   print("Not running in the main thread")
 
   print("Not running in the main thread")
 
end
 
end
</pre>
+
</syntaxhighlight>
  
 
{{LuaSeeAlso}}
 
{{LuaSeeAlso}}
 +
 +
{{Threads}}

Latest revision as of 20:53, 26 June 2026

⚠️ Version Notice

This function requires Cheat Engine 6.4+.

<> Lua API Reference

function inMainThread() : boolean

Returns true if the current code is running inside the main thread.

This function is available in Cheat Engine 6.4 and later.

Function Parameters[edit]

This function has no parameters.

Returns[edit]

boolean — True if the current code is running inside the main thread, otherwise false.

Examples[edit]

1 if inMainThread() then
2   print("Running in the main thread")
3 else
4   print("Not running in the main thread")
5 end

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Thread Related Lua Functions

CPU information, process threads, main-thread execution, and queued callbacks