From 37cdaab54ac6b7ac773b6e44b8f976de460acbb5 Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Wed, 31 May 2023 15:25:29 +0200 Subject: [PATCH] quick cleanup on IPlatform --- ControllerCommon/Platforms/IPlatform.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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 { }