Solved

Displaying the thread ID

Posted on 2009-05-05
3
516 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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