CPU and RAM Meter in C#

This is a simple tutorial that will have a simple CPU and RAM meter by using C#. With this, you will be able to know the usage of your RAM and CPU. And it also calculates the percentage of its performance usage. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio 2010: Go to File, click New Project, and choose Windows Application. 2. Add two PerformanceCounters, “pcCPU” and the other one is “pcRAM”. Then, name the two Labels into “lblCPU” and “lblRAM”. Then, name the two ProgressBars into “pbCPU”and “pbRAM”. Design your interface like this: design 3. After that, click the “pcCPU” PerformanceCounter and go to the properties, then select “Processor” for the Category Name ,“% Processor Time” for the Counter Name and "_Total" for the Instance Name. design 4. Then, click the other PerformanceCounter named “pcRAM” and go to the properties again, then select “Memory” for Category Name and “ % Commited Bytes in Use” for the Counter Name. design 5. Put this code in your Timer_Tick.
  1. private void Timer1_Tick(System.Object sender, System.EventArgs e)
  2. {
  3. //set the performance value to a progessbar
  4. pbCPU.Value = pcCPU.NextValue;
  5. pgRAM.Value = pcRAM.NextValue;
  6. //set the progress bar value to the label to know what is the percentage of the process.
  7. lblcpu.Text = pbCPU.Value + "%";
  8. lblram.Text = pgRAM.Value + "%";
  9. }
6. Lastly, put this code in your Form_Load.
  1. private void Form1_Load(System.Object sender, System.EventArgs e)
  2. {
  3. //set the interval to 500.
  4. Timer1.Interval = 500;
  5. //start the timer
  6. Timer1.Start();
  7.  
  8. }

Output:

output For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer If you have some queries, feel free to contact the number or e-mail below. Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Comments

Submitted byEdgardo (not verified)on Mon, 08/04/2014 - 23:10

Hello I get the following error from this code: Cannot convert method group 'NextValue' to non-delegate type 'int'. Did you intend to invoke the method?
Submitted byZulfikar Badurdeen (not verified)on Sun, 06/21/2015 - 02:00

In reply to by Edgardo (not verified)

Try This pgRAM.Value = (Int32)pcRAM.NextValue();
Submitted byAncich (not verified)on Wed, 11/06/2019 - 22:42

In reply to by Zulfikar Badurdeen (not verified)

I get this error Additional information: Could not locate Performance Counter with specified category name 'Memory', counter name '% Committed Bytes'.
Submitted byasdfasdfgfgrgtr (not verified)on Wed, 04/15/2015 - 23:07

Hey could you please put you sln to github? That would be awesome, because i get several errors and i dont know why..

Add new comment