I have a program which calls a C++ library. The program processes has a large number of threads (50 - 60). Most of them seem to be created in C++ and I suspect most are susp
You could use Process Explorer to inspect threads. It will tell you in realtime how much CPU each is consuming, and can give you individual stack traces, which will indicate what they are blocked on.
To actually determine the count of active threads, it's necessary to check the ThreadState
property of each thread.
((IEnumerable)System.Diagnostics.Process.GetCurrentProcess().Threads)
.OfType<System.Diagnostics.ProcessThread>()
.Where(t => t.ThreadState == System.Diagnostics.ThreadState.Running)
.Count();