Thread.CurrentThread 属性
获取当前正在运行的线程。
**命名空间:**System.Threading
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
Public Shared ReadOnly Property CurrentThread As Thread
用法
Dim value As Thread
value = Thread.CurrentThread
public static Thread CurrentThread { get; }
public:
static property Thread^ CurrentThread {
Thread^ get ();
}
/** @property */
public static Thread get_CurrentThread ()
public static function get CurrentThread () : Thread
属性值
Thread,它是当前正在运行的线程的表示形式。
示例
该代码示例摘自为 IsThreadPoolThread 属性提供的更大的示例。
Shared Sub ThreadMethod()
Console.WriteLine("ThreadOne, executing ThreadMethod, " & _
"is from the thread pool? {0}", _
Thread.CurrentThread.IsThreadPoolThread)
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( "ThreadOne, executing ThreadMethod, "
"is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " );
}
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0