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 can I get the % CPU usage

How can I get the % CPU usage

Scheduled Pinned Locked Moved C#
question
4 Posts 3 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.
  • R Offline
    R Offline
    robert110
    wrote on last edited by
    #1

    I am needing to find out the current CPU usage to determine if I need to run a service or not. If the computer is currently busy then I would like to pause my win-services for x-amount of time and then run it again so users don’t feel the repercussions of my programming and vice versa. In the Task Manager (at the bottom status bar) we can see the # of processes, CPU Usage etc. How I can get/calculate that? Are there any classes available? Thanks in advance.

    G M R 3 Replies Last reply
    0
    • R robert110

      I am needing to find out the current CPU usage to determine if I need to run a service or not. If the computer is currently busy then I would like to pause my win-services for x-amount of time and then run it again so users don’t feel the repercussions of my programming and vice versa. In the Task Manager (at the bottom status bar) we can see the # of processes, CPU Usage etc. How I can get/calculate that? Are there any classes available? Thanks in advance.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Have a look at System.Diagnostics.PerformanceCounter. If you want to run a process that does not degrade the performance, you can start a thread with the Priority property set to BelowNormal.

      --- Year happy = new Year(2007);

      1 Reply Last reply
      0
      • R robert110

        I am needing to find out the current CPU usage to determine if I need to run a service or not. If the computer is currently busy then I would like to pause my win-services for x-amount of time and then run it again so users don’t feel the repercussions of my programming and vice versa. In the Task Manager (at the bottom status bar) we can see the # of processes, CPU Usage etc. How I can get/calculate that? Are there any classes available? Thanks in advance.

        M Offline
        M Offline
        Marc Clifton
        wrote on last edited by
        #3

        This link[^] should help. Marc

        Thyme In The Country

        People are just notoriously impossible. --DavidCrow
        There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
        People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith

        1 Reply Last reply
        0
        • R robert110

          I am needing to find out the current CPU usage to determine if I need to run a service or not. If the computer is currently busy then I would like to pause my win-services for x-amount of time and then run it again so users don’t feel the repercussions of my programming and vice versa. In the Task Manager (at the bottom status bar) we can see the # of processes, CPU Usage etc. How I can get/calculate that? Are there any classes available? Thanks in advance.

          R Offline
          R Offline
          robert110
          wrote on last edited by
          #4

          Thanks a lot :)

          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