Solved

Displaying the thread ID

Posted on 2009-05-05
3
490 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now