void InstQuit(object sender, InstQuitEventArgs e) { // If the handle has not been created, wait for it to be created. if (!IsHandleCreated) { HandleCreated += (sender2, e2) => InstQuit(sender, e); } else { if (InvokeRequired) { try { this.Invoke((o, args) => InstQuit(sender, e)); } catch (InvalidOperationException error) { Console.WriteLine("Invalid operation: " + error.ToString()); } } else { Message(string.Format("Instance exited with code: {0}", e.ExitCode)); if (e.ExitCode != 0) { gameCrashed = true; this.Visible = true; Message("Crash detected!"); } buttonClose.Enabled = true; if ((AppSettings.Main.AutoCloseConsole || !this.Visible) && !gameCrashed) { Close(); } } } }
void OnInstQuit(object sender, InstQuitEventArgs e) { Invoke((sender2, e2) => { Message("Instance quit"); if (e.ExitCode != 0) { ErrorOccurred = true; } this.Deletable = true; if ((AppSettings.Main.AutoCloseConsole || !Visible) && !ErrorOccurred) { CloseConsole(); } else if (ErrorOccurred) { this.Visible = true; } }); }