我正在尝试在扫描完成时关闭Malwarebytes和其他防病毒程序,目前我正在使用CPU使用率作为扫描完成的标志但是Malwarebytes运行了多个进程,我的程序只接收了一个在大多数时间以0%CPU使用率运行的 这是我的代码
public static PerformanceCounter process_cpu = new PerformanceCounter("Process","% Processor Time", "mbam");
public static Process proc = new Process();
private void timer1_Tick(object sender, EventArgs e)
{
double CPU_use = process_cpu.NextValue();
temp = temp + CPU_use;
Count += 1;
TBX1.Text = Count + ": Seconds Opened";
if (proc.Responding)
{
TBX1.Text += " Status = Running CPU usage is " + CPU_use;
if (temp <= 0 && Count % 20 == 0) //this checks every 20 secs
{
MessageBox.Show("Finished?", "END"); //This is temporary, it will just end the program
}
if (Count % 20 == 0)
{
temp = 0;
}
}
else
{
TBX1.Text += " Status = Not Responding";
}
}
}
有更好的方法吗?或者我将不得不选择正在运行的流程?