To get the status of current thread, use the IsAlive() method −
Firstly, create a new thread −
Thread t = Thread.CurrentThread; t.Name = "Our Thread";
Now, to get the status of the current thread −
t.IsAlive
The following is the complete code −
Example
using System;
using System.Threading;
namespace Demo {
class MyClass {
static void Main(string[] args) {
Thread t = Thread.CurrentThread;
t.Name = "Our Thread";
Console.WriteLine("Status = {0}", t.IsAlive);
Console.ReadKey();
}
}
}Output
Status = True