EN
C# / .NET - get current thread name
13 points
In C# / .NET it is possible to get current thread name in following way.
xxxxxxxxxx
1
using System;
2
using System.Threading;
3
4
public static class Program
5
{
6
private static void Execute()
7
{
8
string name = Thread.CurrentThread.Name;
9
10
Console.WriteLine("Current thread name is " + name);
11
}
12
13
public static void Main(string[] args)
14
{
15
Thread thread = new Thread(Execute);
16
17
thread.Name = "MyThread";
18
thread.Start();
19
}
20
}
Output:
xxxxxxxxxx
1
Current thread name is MyThread