diff --git a/ControllerCommon/Platforms/IPlatform.cs b/ControllerCommon/Platforms/IPlatform.cs index 3af629b67..3422c434f 100644 --- a/ControllerCommon/Platforms/IPlatform.cs +++ b/ControllerCommon/Platforms/IPlatform.cs @@ -52,12 +52,9 @@ protected Process Process return null; _Process = processes.FirstOrDefault(); - if (_Process.HasExited) - return null; - _Process.EnableRaisingEvents = true; + _Process.Exited += _Process_Exited; - _Process.Disposed += _Process_Disposed; return _Process; } @@ -68,14 +65,10 @@ protected Process Process } } - private void _Process_Disposed(object sender, EventArgs e) - { - _Process = null; - } - private void _Process_Exited(object sender, EventArgs e) { _Process.Dispose(); + _Process = null; } public bool IsInstalled; @@ -142,10 +135,10 @@ public virtual bool IsRunning() { try { - if (Process is null) + if (_Process is null) return false; - return !Process.HasExited; + return !_Process.HasExited; } catch { }