Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community that shares solutions with each other.

If you think you have something to add here.

you are welcome with your fresh ideas - List Articles

C#/.NET - thread name

0 contributions
8 points

To name thread in C#/.NET Thread.Name property can be used.

using System;
using System.Threading;

namespace Test
	class Program
		static void Main(string[] args)
			Thread.CurrentThread.Name = "MyMainThread";

			Thread thread = new Thread(() =>
				Console.WriteLine(Thread.CurrentThread.Name + " is stopping");

			thread.Name = "MyFirstThread";

			Console.WriteLine(Thread.CurrentThread.Name + " is stopping");


  • Thread.CurrentThread property - keeps reference to currently executed thread object
  • Thread.Name property - gets and sets thread name


MyFirstThread is stopping
MyMainThread is stopping
Thread.Name helps to identify more precisely threads. Threads window shows all threads with their names during debugging proces. To display the window use menu: Debug->Window->Threads (this menu is available only during debugging process).

Thread names during debugging process


  1. Thread Class - Microsoft Docs
  2. Thread.Name Property - Microsoft Docs
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more