Fix watchdog crashing if DreamDaemon immediately exits

This commit is contained in:
Cyberboss
2017-12-06 12:52:52 -05:00
parent e0db57c740
commit c7a1cfa719
+7 -3
View File
@@ -346,8 +346,12 @@ namespace TGS.Server
CurrentDDLog = DateTime.UtcNow.ToString("yyyy-MM-ddTHH-mm-ssZ");
WriteCurrentDDLog("Starting monitoring...");
}
pcpu = new PerformanceCounter("Process", "% Processor Time", Proc.ProcessName, true);
MemTrackTimer.Start();
try
{
pcpu = new PerformanceCounter("Process", "% Processor Time", Proc.ProcessName, true);
MemTrackTimer.Start();
}
catch (InvalidOperationException) { /*process already exited*/ }
try
{
Proc.WaitForExit();
@@ -357,7 +361,7 @@ namespace TGS.Server
lock (watchdogLock) //synchronize
{
MemTrackTimer.Stop();
pcpu.Dispose();
pcpu?.Dispose();
}
}