Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to get number of running threads?

How to get number of running threads?

Scheduled Pinned Locked Moved C#
questioncsharptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CWIZO
    wrote on last edited by
    #1

    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!

    H 1 Reply Last reply
    0
    • C CWIZO

      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!

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You could use Process.GetProcesses to get all the processes on the system, enumerate them, and use Process.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

      C 1 Reply Last reply
      0
      • H Heath Stewart

        You could use Process.GetProcesses to get all the processes on the system, enumerate them, and use Process.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

        C Offline
        C Offline
        CWIZO
        wrote on last edited by
        #3

        Thanx, I will look into that. Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups