This is a simple example for C# project with form windows.
Create the project and add four labels, two progress bar, timer, two performance Counter and a chart from the Toolbox menu area to your project Form.
Change the performance Counter pCPU and pRAM names.
Change the timer name the timer.
Add the timer_Tick to the timer.
Change the name of the chart to output_chart.
Add series to the chart and named CPU and RAM.
Two labels come with the text: CPU and RAM.
Next two labels come with an output of progress bar vales and are named: lblRAM and lblCPU.
The result can be found on the Download – Application menu website area and is named SysFT.
The source code for this project is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | using System; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; namespace SysFT { public partial class SysFT : Form { public SysFT() { InitializeComponent(); } private void SysFT_Load(object sender, EventArgs e) { timer.Start(); } private void timer_Tick(object sender, EventArgs e) { float fcpu = pCPU.NextValue(); progressBarCPU.Value = (int)fcpu; lblCPU.Text = string.Format("{0:0.00}%", fcpu); float fram = pRAM.NextValue(); progressBarRAM.Value = (int)fram; lblRAM.Text = string.Format("{0:0.00}%", fram); output_chart.Series["CPU"].Points.AddY(fcpu); output_chart.Series["RAM"].Points.AddY(fram); if (output_chart.Series["CPU"].Points.Count > 30) { output_chart.Series["CPU"].Points.Clear(); output_chart.Series["RAM"].Points.Clear(); } } } } |