RAM and CPU Meter

RAM and CPU Meter in C#

Details: RAM and CPU Meter

RAM is short for random access memory, a type of memory in a computer that can be used to store data temporarily. RAM is essential in any computer as it allows the system to perform tasks quickly. RAM is measured in gigabytes, megabytes, and terabytes. The amount of RAM a computer has affects its performance and it’s also customizable.

In this post, we will illustrate how to create a basic CPU and RAM meter utilizing the C# programming language. We can be able to know the usage of our RAM and CPU, and also calculate the percentage of its performance usage with this program.

Guide: RAM and CPU Meter

1 – We start by creating a Windows Form Application in C# through Microsoft Visual Studio 2019 following these steps;
– Navigate to File
– Click on New Project
– Select Windows Application

2 – We can now, add 2 PerformanceCounters;
– “pcCPU” labelled as lblCPU, and,
– “pcRAM” labelled as lblRAM.
Also name the 2 ProgreessBars as “pbCPU” AND “pbRAM” respectively.
Your interface should be designed like the image below.

3 – Now, Tap on the “pcCPU” PerformanceCounter and navigate to the properties choose “Processor” as the Category Name.
– “%Processor Time” will serve as Count Name
– “_Total” will serve as Instance Name.

4 – Proceed to click on the other PerformanceCounter labelled “pcRAM”
– Navigate to the properties again, and,
– Select “Memory” as Category Name
– “% Committed Bytes in Use” as Counter Name.

5. Insert the below 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, insert 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

Outputs: RAM and CPU Meter

RAM and CPU Meter in C#, free source code, programming language, c# tutorial

Recommended: Show Full Screen Mode in C# FREE

Don’t forget to share this post!

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Article