This item was deprecated in version 2020r2. Please use Thread as a replacement.
Used to run code in the background. Xojo threads are co-operative (not pre-emptive).
These are the various states of a thread. (Running, Waiting, Suspended, Sleeping, NotRunning)
The thread is currently running.
The thread is waiting to run.
The thread is suspended.
The thread is sleeping.
The thread is not running.
Priority As Integer
Indicates the priority of the thread.
The main thread for the app has a priority of 5. You can alter the priority of your own threads to give them more or less time relative to the main thread. The default is also 5.
The higher the priority value, the more time the thread is allocated, in relation to the main thread. For example, if you set the Priority = 10, then your thread will run twice as often as the main thread (since 10 is 5*2). A Priority value that is too high might prevent other threads from running at all.
Set the thread to a low priority:
Thread1.Priority = Thread.PriorityLow
StackSize As UInteger
The size of the thread stack, in bytes.
State As ThreadStates
Indicates the state of the thread using the ThreadStates enumeration.
This property is read-only.
Check the state of a thread:
Var status As Text
Select Case state
status = "Running"
status = "Waiting"
status = "Waiting"
status = "Suspended"
status = "Not running"
Wakes a thread that is sleeping or suspended so that it may continue running.
Starts the thread and calls its Run event handler.
Puts the thread to sleep for the specified amount of milliSeconds, optionally allowing it to be woken early.
If wakeEarly is True, a thread may be woken before milliSeconds is reached if there are no other threads to run.
Puts the thread in a suspended state where it will no longer run. You can allow the thread to continue by calling Resume.
When a thread is suspended, it is not allocated any processing time, regardless of its priority.
' Other code goes here
Called when the thread is started by calling the Run method. The code you want to run in the thread should be in this event handler or should be called from it.
All project types on all supported operating systems.