这段代码使我的WPF程序崩溃
void DoButton(object sender, RoutedEventArgs e)
{
int i = 0;
int x = 0;
PerformanceCounter cpuCounter;
cpuCounter = new PerformanceCounter();
cpuCounter.CategoryName = "Processor";
cpuCounter.CounterName = "% Processor Time";
cpuCounter.InstanceName = "_Total";
while (modus == 0)
{
float currentCpuUsage = cpuCounter.NextValue();
TextOutput.Text = "" + currentCpuUsage;
Thread.Sleep(300);
}
}
没有错误消息,但整个窗口崩溃了