I have a problem: my performance program always shows 0% CPU Usage...
I Have added 1 label called Text value CPU:
Here is the code:
public partial class Form1 : Form
{
PerformanceCounter cpu = new PerformanceCounter ("Processor", "% Processor Time", "_Total");
public Form1()
{
InitializeComponent();
//string cpu_ussage =
Text.Text = "CPU: " + CPU_TIME();
}
// Provjera Procesa koristeći %
public string CPU_TIME()
{
float cpu_time;
cpu_time = cpu.NextValue();
return Math.Round(Convert.ToDouble(cpu_time.ToString()), 2) + "%";
}
private void timer1_tick(object sender, EventArgs e)
{
Text.Text = "CPU Time:" + CPU_TIME();
}
}