Windows Forms: Create CPU & Memory Monitor using Metro Modern UI in C#

By FoxLearn 6/3/2017 6:12:34 PM   8.09K
How to Create CPU & Memory Monitor in C# using Metro Framework, Modern UI.

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "CPURAM" and then click OK

cpu and ram monitor with real time chart

Step 2: Right click on your project select Manage NuGet Packages -> Search metro framework -> Install

install metro framework

If you don't see the metro framework in your toolbox, you can view How to download and install metro framework

Step 3: Design your metro form as below

cpu meter c#

Step 4: Add Timer and PerformanceCounter to metro form, then add a tick event handler to timer

using System;

namespace CPURAM
{
    public partial class Form1 : MetroFramework.Forms.MetroForm
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            float fcpu = pCPU.NextValue();
            float fram = pRAM.NextValue();
            //Set value to cpu and ram</span>
            metroProgressBarCPU.Value = (int)fcpu;
            metroProgressBarRAM.Value = (int)fram;
            //Update value to cpu and ram label</span>
            lblCPU.Text = string.Format("{0:0.00}%", fcpu);
            lblRAM.Text = string.Format("{0:0.00}%", fram);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer.Start();
        }
    }
}

VIDEO TUTORIALS