Updated Thread (markdown)
10
Thread.md
10
Thread.md
@@ -33,7 +33,15 @@ stops the thread
|
|||||||
````lua
|
````lua
|
||||||
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
local mainFrame = basalt.createFrame("myFirstFrame"):show()
|
||||||
local aThread = mainFrame:addThread("myFirstThread"):show()
|
local aThread = mainFrame:addThread("myFirstThread"):show()
|
||||||
basalt.debug(aThread:getStatus()) -- returns "running", "normal", "suspended" or "dead"
|
local function randomThreadFunction()
|
||||||
|
while true do
|
||||||
|
basalt.debug("Thread is active")
|
||||||
|
os.sleep(1) -- a sleep/coroutine.yield() or pullEvent is required otherwise we will never come back to the main program (error)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
aThread:start(randomThreadfunction)
|
||||||
|
local aButton = mainFrame:addButton("myFirstButton"):setText("Stop Thread"):onClick(function() aThread:stop() end):show()
|
||||||
|
|
||||||
````
|
````
|
||||||
**parameters:** -<br>
|
**parameters:** -<br>
|
||||||
**returns:** self<br>
|
**returns:** self<br>
|
||||||
Reference in New Issue
Block a user