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:
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.
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
Timer1.Start();
}
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