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?