Export (0) Print
Expand All

Thread.CurrentThread Property

Gets the currently running thread.

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

Property Value

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

Example

[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}", _
        Thread.CurrentThread.IsThreadPoolThread)
End Sub

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

[C++] 
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.

Requirements

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

Show:
© 2015 Microsoft