private void timerKillIfFrozen_Elapsed(object sender, ElapsedEventArgs e) {
if (isHandlingEvent)
return;
timerKillIfFrozen.Interval = 2000;
isHandlingEvent = true;
if (api.MpcProcess != null && !api.MpcProcess.HasExited && !api.MpcProcess.Responding) {
bool Responding = false;
for (int i = 0; i < 6; i++) {
System.Threading.Thread.Sleep(200);
if (api.MpcProcess.Responding) {
Responding = true;
break;
}
}
if (!Responding) {
try {
api.MpcProcess.Kill();
}
catch {
}
api.MpcProcess = null;
System.Threading.Thread.Sleep(500);
}
}
if (api.MpcProcess != null && !api.MpcProcess.HasExited)
runAttemps = 0;
if (!AllowClose)
EnsureRunning();
isHandlingEvent = false;
}