我有以下代码,它只允许我的应用程序在 CPU 使用率低于一定时间后打开。但是我只需要一些帮助来添加一些东西,以确保使用率保持在这个低水平至少 5 秒,这样我就可以避免 CPU 使用率的任何下降峰值。
cpuUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");
var usage = cpuUsage.NextValue();
do
{
Thread.Sleep(TimeSpan.FromSeconds(1));
usage = cpuUsage.NextValue();
Console.WriteLine(usage + "%");
} while (usage > 10.00);
Process proc = new Process();
proc.StartInfo = new ProcessStartInfo(@"C:\Documents and Settings\rcgames\Desktop\Game1.exe");
proc.Start();