
To check the status of the current thread in C#, use the IsAlive property.
Firstly, use the currentThread property to display information about a thread −
Thread thread = Thread.CurrentThread;
Now use the thread.IsAlive property to check the status of the thread −
thread.IsAlive
Let us see the complete code to check the status of current thread in C#.
Live Demo
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
The above is the detailed content of C# program to check current thread status. For more information, please follow other related articles on the PHP Chinese website!
How to open the terminal window in vscode
What is ECharts
How to enter recovery mode on win10 system computer
Complete collection of SQL query statements
Is it difficult to learn Java by yourself?
What is the shortcut key for switching users?
How to take screenshots on Huawei mate60pro
PHP server introduction