How to Check Status of Current Thread in C# ?

This blog post will provide a simple tip on how you can find the status of the current thread in C# program.

How to Check Status of Current Thread in C# ?

The isAlive property can be used to check the current thread status in C#. First , get the instance of the current thread using the Thread.CurrentThread and then get the IsAlive property. Ensure that you add the namespace using System.Threading to your C# file.

var currentThreadStatus = Thread.CurrentThread.IsAlive;

Below is a sample code snippet demonstrating how to check the status of the current thread in C#.

using System;
using System.Threading;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            var currentThreadStatus = Thread.CurrentThread.IsAlive;
            Console.WriteLine(currentThreadStatus);
        }
    }
}
Tags :

Leave Your Comment

Liked this content?. Please spread the word :)