

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Program to display name of Current Thread
To display the name of the current thread in C#, use the Name property.
Firstly, use the currentThread property to display information about a thread −
Thread thread = Thread.CurrentThread;
Now use the thread.Name property to display name of the thread −
thread.Name
Example
Let us see the complete code show current thread’s name in C#.
using System; using System.Threading; namespace Demo { class MyClass { static void Main(string[] args) { Thread thread = Thread.CurrentThread; thread.Name = "My Thread"; Console.WriteLine("Thread Name = {0}", thread.Name); Console.ReadKey(); } } }
Output
Thread Name = My Thread
- Related Questions & Answers
- How to display the name of the Current Thread in C#?
- How to get current thread name in android?
- Fetching the name of the current thread in Java
- C# Program to Check status of Current Thread
- C# Program to display priority of Thread
- Display the current method name in Java
- How to display all stack frames of the current thread in Java 9?
- C# Program to display the name of the directory
- How to get getAllStackTraces of current thread in android?
- Get current thread in Java
- Java Program to Display current Date and Time
- How to set Thread name in TestNG?
- How to obtain Status of the Current Thread in C#?
- How to check current state of a thread in C#?
- How to get current thread count in android?
Advertisements