RAM And CPU Meter In C#

ram and cpu meter in c#

This tutorial is about creating a simple CPU and RAM meter using C#. This program will be able to know the usage of your RAM and CPU. In addition, it calculates the percentage of its performance usage.

Let’s start this tutorial!

1. Create a Windows Form Application in C# for this tutorial by following the steps in Microsoft Visual Studio 2019: 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:


3. Then, 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.


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.


5. Put this code in your Timer_Tick.

private void Timer1_Tick(System.Object sender, System.EventArgs e)
    //set the performance value to a progessbar
    pbCPU.Value = pcCPU.NextValue;
    pgRAM.Value = pcRAM.NextValue;
    //set the progress bar value to the label to know what is the percentage of the process.
    lblcpu.Text = pbCPU.Value + "%";
    lblram.Text = pgRAM.Value + "%";


6. Lastly, put this code in your Form_Load.

private void Form1_Load(System.Object sender, System.EventArgs e)
    //set the interval to 500.
    Timer1.Interval = 500;
    //start the timer



Sharing is caring!

Facebook Comments

Leave a Reply