0

In my application I want to display CPU and memory usage in every time intervel of 1 second.

I'am using PerformanceCounter to get this information, but it is not correct with CPU usage of system. Please find the the code that are used in my application. This code is written in the timer tick event.

PerformanceCounter cpuCounter;
cpuCounter = new PerformanceCounter("Processor", "% Privileged Time", "_Total");
lbl_cpu_usage.Text = Convert.ToInt32(cpuCounter.NextValue()).ToString() + "%";
Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
Rahul S Menon
  • 23
  • 1
  • 4
  • There are c# functions for it but to be honest I prefer using a c++ library I wrote, since c++ is faster in handling such tasks. If you are interested I can search that dll I wrote and post the source here. Just can't promise I will find it, wrote that some time ago as apprentice :) – Nico Mar 02 '17 at 10:54
  • 2
    @Nico Not to be rude but it's probably best to save commenting about your library in the future unless you have a link to the library. A comment saying "I wrote a C++ library that does this" isn't helpful at all – James Gould Mar 02 '17 at 11:01
  • @JayGould I understand that :) . But as mentioned I said that if he is interested in implementing a dll in his project I can put the source code here. I am curently at work and don't have access to it but when I am at home I can post it. – Nico Mar 02 '17 at 11:47

0 Answers0