Fixes stopping the server causing endless exceptions

This commit is contained in:
Cyberboss
2017-10-24 11:17:18 -04:00
parent 3c9cccb5f2
commit 215561eec8
+11 -5
View File
@@ -344,14 +344,20 @@ namespace TGServerService
{
CurrentDDLog = String.Format("{0} {1} Diagnostics.txt", Now.ToLongDateString(), Now.ToLongTimeString()).Replace(':', '-');
WriteCurrentDDLog("Starting monitoring...");
pcpu = new PerformanceCounter("Process", "% Processor Time", Proc.ProcessName, true);
}
pcpu = new PerformanceCounter("Process", "% Processor Time", Proc.ProcessName, true);
MemTrackTimer.Start();
Proc.WaitForExit();
lock (watchdogLock) //synchronize
try
{
MemTrackTimer.Stop();
pcpu.Dispose();
Proc.WaitForExit();
}
finally
{
lock (watchdogLock) //synchronize
{
MemTrackTimer.Stop();
pcpu.Dispose();
}
}
WriteCurrentDDLog("Crash detected!");