Thread.ThreadState Property


Gets a value containing the states of the current thread.

Namespace:   System.Threading
Assembly:  mscorlib (in mscorlib.dll)

Public ReadOnly Property ThreadState As ThreadState

Property Value

Type: System.Threading.ThreadState

One of the ThreadState values indicating the state of the current thread. The initial value is Unstarted.

The ThreadState property provides more specific information than the IsAlive property.


Thread state is only of interest in debugging scenarios. Your code should never use thread state to synchronize the activities of threads.

The following code example demonstrates accessing the ThreadState of a thread.

Imports System.Threading

Public Module Example
    Public Sub Main()
        Dim newThread As Thread = New Thread(AddressOf ThreadMethod)

        Console.WriteLine("ThreadState: {0}", newThread.ThreadState)

        ' Wait for newThread to start and go to sleep.
        Console.WriteLine("ThreadState: {0}", newThread.ThreadState)

        ' Wait for newThread to restart.
        Console.WriteLine("ThreadState: {0}", newThread.ThreadState)
    End Sub

    Sub ThreadMethod()
    End Sub
End Module
' The example displays the following output:
'       ThreadState: Unstarted
'       ThreadState: WaitSleepJoin
'       ThreadState: Stopped

.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top