Solved

Displaying the thread ID

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

18 Experts available now in Live!

Get 1:1 Help Now