Basalt 1.7 Update
- New Objects (Flexbox, Graph, Treeview) - Pluginsystem to add/remove functionality - Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject - Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox - Removed the Animation Object, and added a animation plugin instead - Removed the Graphic Object and merged it's functionality with the image object - Updated currently existing objects
This commit is contained in:
@@ -1,7 +1,33 @@
|
||||
## Methods
|
||||
Threads are objects that allow you to run code concurrently in the background, without blocking the main program. They use coroutines in the background to achieve this behavior. Threads do not inherit from the VisualObject class, as they are not visible elements.
|
||||
|
||||
In addition to the Object methods, Threads have the following methods:
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
|[start](objects/Thread/start.md)|starts a new thread and executes the function
|
||||
|[stop](objects/Thread/stop.md)|stops the currently running thread
|
||||
|[start](objects/Thread/start.md)|Starts a new thread and executes the specified function
|
||||
|[stop](objects/Thread/stop.md)|Stops the currently running thread
|
||||
|[getStatus](objects/Thread/getStatus.md)|Returns the current thread status
|
||||
|
||||
## Example
|
||||
|
||||
Here's an example of how to create and use a Thread object:
|
||||
|
||||
```lua
|
||||
-- Function that will be executed in a separate thread
|
||||
local function backgroundTask()
|
||||
for i = 1, 5 do
|
||||
basalt.debug("Running in the background:", i)
|
||||
os.sleep(1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Create a new Thread object
|
||||
local main = basalt.createFrame()
|
||||
local myThread = main:addThread()
|
||||
|
||||
-- Start the thread
|
||||
myThread:start(backgroundTask)
|
||||
|
||||
-- Optionally stop the thread (not needed in this example, as the thread will finish on its own)
|
||||
-- myThread:stop()
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user