static void Process_Exited(object sender, EventArgs e) { Process proc = (Process)sender; proc.Exited -= Process_Exited; proc.Dispose(); GameProcessExited?.Invoke(); }
static void Process_Exited(object sender, EventArgs e) { Logger.Log("GameProcessLogic: Process exited."); Process proc = (Process)sender; proc.Exited -= Process_Exited; proc.Dispose(); GameProcessExited?.Invoke(); }
private void OnGameProcessExited() { try { GameProcessExited?.Invoke(this, new EventArgs()); } catch (Exception ex) { ex.Log(); } }
public void NotifyGameProcessExited() { try { GameProcessExited?.Invoke(this, EventArgs.Empty); } catch (Exception ex) { ex.Log(); } SendCommand("GPE", (sender, e) => { // NOP }); }
public void MonitorGameProcess() { if (DateTime.Now.Ticks < GameProcessNextCheckTime) { return; } GameProcessNextCheckTime = DateTime.Now.AddSeconds(5).Ticks; Process gameProcess = GameProcess; if (gameProcess == null) { ("NoGameProcess for " + this.Settings.Name).Log(); return; } try { var pid = gameProcess.Id; gameProcess.Refresh(); if (ElectChildProcess(pid)) { // gameProcess = GameProcess; } else if (gameProcess.HasExited || gameProcess.MainWindowHandle == IntPtr.Zero) { if (gameProcess.HasExited) { lock (_processes) { _processes.Remove(gameProcess); } } if (_processes.Count > 0) { var processes = _processes.ToArray(); foreach (var L_process in processes) { try { L_process.Refresh(); if (L_process.HasExited) { lock (_processes) { _processes.Remove(L_process); } } else if (L_process.MainWindowHandle != IntPtr.Zero) { ("PreviousGameProcess for " + this.Settings.Name + " pid=" + L_process.Id + " hwnd=" + L_process.MainWindowHandle.ToString("X")).LogInfo(); pid = L_process.Id; GameProcess = L_process; Sandbox.Process = L_process; break; } } catch { lock (_processes) { _processes.Remove(L_process); } } } } if (_processes.Count == 0) { ("GameExitDetected for " + this.Settings.Name).LogWarn(); GameProcess = null; Sandbox.Process = null; Settings.WindowHandle = IntPtr.Zero; if (NetworkClient != null) { NetworkClient.WindowHandle = Settings.WindowHandle; } GameProcessExited?.Invoke(this, new EventArgs()); } } else { IntPtr newWindowHandle = IntPtr.Zero; if (gameProcess.Responding) { newWindowHandle = gameProcess.MainWindowHandle; if (NetworkClient != null) { NetworkClient.WindowHandle = newWindowHandle; } bool newProcessWindow = Settings.WindowHandle != newWindowHandle; if (newProcessWindow) { ("NewGameProcess for " + this.Settings.Name).Log(); WinAPI.SandboxApi.TryFixMultilaunch(gameProcess); Settings.WindowHandle = newWindowHandle; GameProcessFound?.Invoke(this, new EventArgs()); } if (gameProcess.PriorityClass != ProcessPriorityClass.Idle) { gameProcess.PriorityClass = ProcessPriorityClass.Idle; } ManageProcessorAffinity(gameProcess); } else { ("GameProcessNotResponding for " + this.Settings.Name).LogWarn(); } } } catch (Exception ex) { ex.Log(); } }
private void proc_Exited(object sender, EventArgs e) { GameProcessExited?.Invoke(this, e); }