Why do System.Diagnostics.GetCurrentProcess().Threads.Count
, the Task Manager, and the Visual Studio Debugger all report a different number of threads?
I found this: Why does the number of threads reported by WinDbg, Task Manager and VS Debugger differ?
And it indicated that the debugger performs some form of filtering, but there was never an answer as to what the filter was. There was also a note about invasive vs non-invasive methods of obtaining the thread count and how that might effect the reported amount by the task manager.
What I am seeing is that System.Diagnostics.GetCurrentProcess().Threads.Count
reports a larger number of threads than the Task Manager, which reports a larger number of threads than the Debugger.
Is System.Diagnostics.GetCurrentProcess().Threads.Count
ultimately the most accurate or is there something erroneous or misleading in what it reports? It would also be nice to know what filtering is being applied by the Visual Studio Debugger (and seemingly the Task Manager as well, albeit a different filter).