I need to update my label
at all times when I use timer
it updates, but it crashes the program
Program.cs
public static String Uso()
{
ManagementClass mc = new ManagementClass("win32_processor");
ManagementObjectCollection moc = mc.GetInstances();
String Id = String.Empty;
foreach (ManagementObject mo in moc)
{
Id = mo.Properties["LoadPercentage"].Value.ToString();
break;
}
return Id;
}
Form1.cs
private void timer1_Tick(object sender, EventArgs e)
{
label42.Text = Program.HardwareInfo.Uso();
}
I can not find a way to update the processor usage information and let my program run normally.