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. cpu performance with wmi ...

cpu performance with wmi ...

Scheduled Pinned Locked Moved C#
questioncsharpdatabasetoolsperformance
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.
  • S Offline
    S Offline
    SungBae Han
    wrote on last edited by
    #1

    how can i get usage cpu performance from wmi based on c# ? many solution just write about sql script or the other.

    S V 2 Replies Last reply
    0
    • S SungBae Han

      how can i get usage cpu performance from wmi based on c# ? many solution just write about sql script or the other.

      S Offline
      S Offline
      SungBae Han
      wrote on last edited by
      #2

      when i use PerformanceCounter, it can get a information cpu performance. but it just cpu own. i.e, case of invoke progressbar, it can display cpu usage rate. it just one thread. but i wanna get a cpu,network and memory usage rate. so i make them in one thread. but always cpu usage rate 0% in my project. i don't understand it. following my code. ------------------------ PerformanceCounter p = new PerformanceCounter(); p.CategoryName = "Processor"; p.CounterName = "% Processor Time"; p.InstanceName = "_Total"; ... progressbar invoke ... float usage = p.NextValue(); progressBar1.Value = ((int)usage); label1.Text = "CPU usage : " + ((int)usage).ToString() + "%"; ..... it can display useage rate... i write this code in my project, but case on my project. it can't display performance. :(

      1 Reply Last reply
      0
      • S SungBae Han

        how can i get usage cpu performance from wmi based on c# ? many solution just write about sql script or the other.

        V Offline
        V Offline
        Valery Possoz
        wrote on last edited by
        #3

        Hello, Have you tried this:

                ManagementObject processor = new ManagementObject("Win32\_PerfFormattedData\_PerfOS\_Processor.Name='\_Total'");
                processor.Get();
                ulong value = (ulong)processor.Properties\["PercentProcessorTime"\].Value;
        

        Valery.

        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