Gets a numeric value indicating the execution state of the thread specified by thread_object.
state_var = thread_object.ThreadState
Prerequisites
None
Parameters
None
Remarks
This property returns information about a thread’s execution state. The numeric value returned by this property is described in Table 19-106.
ThreadState Value | Description |
---|---|
-1 |
The thread does not exist. Either it was never started or it was stopped and deleted by an Abort method. |
0 |
The thread has completed execution normally and is idle. It cannot be resumed, but it can be restarted with Start. |
1 |
The thread is stopping execution. This state is transient. |
2 |
The thread is executing normally. |
3 |
The thread is paused without error and can be resumed. |
4 |
The thread is paused with an error. If it is resumed, it will retry the instruction that caused the error. |
Examples
Dim thread1 As New Thread(“Test”) ' Create a thread object to execute the
' procedure Test in the current project
thread1.Start() ' Start the thread
Console.Writeline(thread1.ThreadState) ' Display the state code for thread1
See Also