This documentation is archived and is not being maintained.

Thread.CurrentThread Property

Gets the currently running thread.

[Visual Basic]
Public Shared ReadOnly Property CurrentThread As Thread
public static Thread CurrentThread {get;}
public: __property static Thread* get_CurrentThread();
public static function get CurrentThread() : Thread;

Property Value

A Thread that is the representation of the currently running thread.


[Visual Basic, C#, C++] This code example is part of a larger example provided for the IsThreadPoolThread property.

[Visual Basic] 
Shared Sub ThreadMethod()
    Console.WriteLine("ThreadOne, executing ThreadMethod, " & _
        "is from the thread pool? {0}", _
End Sub

static void ThreadMethod()
    Console.WriteLine("ThreadOne, executing ThreadMethod, " +
        "is {0}from the thread pool.", 
        Thread.CurrentThread.IsThreadPoolThread ? "" : "not ");

static void ThreadMethod()
    Console::WriteLine(S"ThreadOne, executing ThreadMethod, "
        S"is {0}from the thread pool.", 
        Thread::CurrentThread->IsThreadPoolThread ? S"" : S"not ");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Thread Class | Thread Members | System.Threading Namespace