How to get number of running threads?
-
Hi, how can I get the number of running threads on the machine. Not just the ones I have created but all threads. I have googeled a little but didn't find anything useful ... Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
-
Hi, how can I get the number of running threads on the machine. Not just the ones I have created but all threads. I have googeled a little but didn't find anything useful ... Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
You could use
Process.GetProcesses
to get all the processes on the system, enumerate them, and useProcess.Threads.Count
to tally a count. Depending on your privileges, though, this might not represent all the threads in the system (only those for which you have access to the processes). There's also a way using WMI, but it's more difficult to implement and will be slower. Besides, your credentials are typically used when accessing the WMI host so you'll most likely run into the problem described above.Microsoft MVP, Visual C# My Articles
-
You could use
Process.GetProcesses
to get all the processes on the system, enumerate them, and useProcess.Threads.Count
to tally a count. Depending on your privileges, though, this might not represent all the threads in the system (only those for which you have access to the processes). There's also a way using WMI, but it's more difficult to implement and will be slower. Besides, your credentials are typically used when accessing the WMI host so you'll most likely run into the problem described above.Microsoft MVP, Visual C# My Articles