Solved

Displaying the thread ID

Posted on 2009-05-05
3
505 Views
Last Modified: 2012-05-06
Experts,

How does one display the thread ID for identifying what tasks are running in a thread?
0
Comment
Question by:nickmarshall
  • 2
3 Comments
 
LVL 6

Assisted Solution

by:ViceroyFizzlebottom
ViceroyFizzlebottom earned 250 total points
ID: 24305636
Thread.CurrentThread.Name
0
 
LVL 6

Assisted Solution

by:ViceroyFizzlebottom
ViceroyFizzlebottom earned 250 total points
ID: 24305663
Or actually, more specific to your question:
Thread.CurrentThread.GetHashCode();

Here's a good article on threading in .NET:
http://www.code-magazine.com/Article.aspx?quickid=0309071
0
 
LVL 9

Accepted Solution

by:
tculler earned 250 total points
ID: 24306242
What thread are you looking to get the ID for? You can use the ManagedThreadID instance property of any Thread object, the Name instance property, or GetHashCode() should work as well.

If you're looking to get the Threads in a certain process, create an instance of a System.Diagnostics.Process object that is linked to that process, and use the "Threads" instance property. This returns a collection of the Threads currently running in that given process. If you want the threads in the current process, call System.Diagnostics.Process.GetCurrentProcess().Threads.

Hope I helped,
Nate
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question