We help IT Professionals succeed at work.
Get Started

Thread monitoring by name

Last Modified: 2012-06-21
In C# you can create a thread by the following:

            System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(testMethod));
            t.Name = "TESTING";

Notice I have initialized the "Name" property of the thread before starting it.
Is there any way to monitor (through perfmon or wmi or other) the CPU activity of this thread by name?

The reason I ask is that the ultimate goal I have is in an application that is relatively thread-heavy, and I'd like to know where time is getting spent where, and when there are random hangups, know where I am stuck. I would know this by seeing the CPU utilization of a particular named thread going nuts.

Here's what I've discovered so far:
WMI Class Win32Thread - Almost useless, doesn't contain names or threads, etc.
WMI Class Win32_PerfRawData_PerfProc_Thread - Contains names but it is Process\#, not the Thread.Name property, so I have no way to link the two.  This also contains CPU Utilization, but without knowing which thread is which, this is not useful to me.

Perfmon also allows the "Thread" monitoring by a name similar to the PerfRawData WMI class, i.e., Process\#

Anyone know how to accomplish what I'm after?
Watch Question
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE