
##要在 C# 中檢查目前執行緒的狀態,請使用
IsAlive 屬性。
首先,使用currentThread 屬性顯示有關線程的資訊-
Thread thread = Thread.CurrentThread;
thread.IsAlive 屬性檢查線程的狀態-
thread.IsAlive
using System;
using System.Threading;
namespace Demo {
class MyClass {
static void Main(string[] args) {
Thread thread = Thread.CurrentThread;
thread.Name = "My New Thread";
Console.WriteLine("Thread Status = {0}", thread.IsAlive);
Console.ReadKey();
}
}
}Thread Status = True
以上是檢查目前執行緒狀態的 C# 程序的詳細內容。更多資訊請關注PHP中文網其他相關文章!