0

Is there a way to monitor processor time of each thread in a WPF application?

I implemented a wrapper as described here and attempted to cross reference with thread performance counters:

I retrieved the threads for the application using the following performance counters:

Thread/<appname>/<thread number>

I then tried to match those against the managedThreadId of each Thread, but the ID does not appear to match the instance number.

Community
  • 1
  • 1
brightbulb
  • 11
  • 3
  • Could you be more specific about how you attempted to "cross reference" and in what way it wasn't successful? – Brian Reichle Nov 16 '15 at 12:41
  • I elaborated in the question – brightbulb Nov 17 '15 at 00:57
  • The thread number in your performance counter would be the Thread ID allocated by windows. ManagedThreadID is an entirely different value allocated by .NET. – Brian Reichle Nov 17 '15 at 07:55
  • You could pinvoke GetCurrentThreadId (technically, the CLR is allowed to switch managed threads between OS threads - which would make the result unreliable - but I don't think it currently does so). You would probably be better off just finding a profiler that gives you what you want. – Brian Reichle Nov 17 '15 at 08:06

0 Answers0