protected override void OnExit(ExitEventArgs e) { //X.Instance.Try(PlayDispatcher.Instance.Dispose); ExceptionlessClient.Default.Shutdown(); // Fix: this can happen when the user uses the system close button. // If a game is running (e.g. in StartGame.xaml) some threads don't // stop (i.e. the database thread and/or the networking threads) X.Instance.Try(Program.StopGame); Sounds.Close(); base.OnExit(e); }
protected override void OnExit(ExitEventArgs e) { X.Instance.Try(PlayDispatcher.Instance.Dispose); ExceptionlessClient.Current.Shutdown(); // Fix: this can happen when the user uses the system close button. // If a game is running (e.g. in StartGame.xaml) some threads don't // stop (i.e. the database thread and/or the networking threads) if (Program.IsGameRunning) { Program.StopGame(); } Sounds.Close(); try { Program.Client.Rpc.Leave(Player.LocalPlayer); } catch { } base.OnExit(e); }
public static void Exit() { try { SSLHelper.Dispose(); } catch (Exception e) { Log.Error("SSLHelper Dispose Exception", e); }; Sounds.Close(); UpdateManager.Instance.Stop(); LogManager.Shutdown(); Application.Current.Dispatcher.Invoke(new Action(() => { if (LobbyClient != null) { LobbyClient.Stop(); } WindowManager.Shutdown(); //Apparently this can be null sometimes? if (Application.Current != null) { Application.Current.Shutdown(0); } })); }
private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = (Exception)e.ExceptionObject; var handled = false; var ge = Program.GameEngine; var gameString = ""; if (ge?.Definition != null) { gameString = "[Game " + ge.Definition.Name + " " + ge.Definition.Version + " " + ge.Definition.Id + "] [Username " + Prefs.Username + "] "; } if (ex is UserMessageException) { if ((ex as UserMessageException).Mode == UserMessageExceptionMode.Blocking || WindowManager.GrowlWindow == null) { ShowErrorMessageBox("Error", ex.Message); } else { WindowManager.GrowlWindow.AddNotification(new ErrorNotification(ex.Message)); } Log.Warn("Unhandled Exception " + gameString, ex); handled = true; } else if (ex is XamlParseException) { var er = ex as XamlParseException; Log.Warn("unhandled exception " + gameString, ex); handled = true; ShowErrorMessageBox("Error", "There was an error. If you are using Wine(linux/mac) most likely you didn't set it up right. If you are running on windows, then you should try and repair your .net installation and/or update windows. You can also try reinstalling OCTGN."); } else if (ex is IOException && (ex as IOException).Message.Contains("not enough space")) { handled = true; ShowErrorMessageBox("Error", "Your computer has run out of hard drive space and OCTGN will have to shut down. Please resolve this before opening OCTGN back up again."); } if (!handled) { if (e.IsTerminating) { Log.Fatal("UNHANDLED EXCEPTION " + gameString, ex); } else { Log.Error("UNHANDLED EXCEPTION " + gameString, ex); } } if (e.IsTerminating) { if (handled) { ShowErrorMessageBox("Error", "We will now shut down OCTGN.\nIf this continues to happen please let us know!"); } else { ShowErrorMessageBox("Error", "Something unexpected happened. We will now shut down OCTGN.\nIf this continues to happen please let us know!"); } Sounds.Close(); Application.Current.Shutdown(-1); } }
private void Signal_OnException(object sender, ExceptionEventArgs args) { Log.Fatal("Signal_OnException: " + args.Message, args.Exception); Sounds.Close(); Application.Current.Shutdown(-1); }
public static void Exit() { try { SSLHelper.Dispose(); } catch { } Sounds.Close(); try { Program.Client.Rpc.Leave(Player.LocalPlayer); } catch { } UpdateManager.Instance.Stop(); LogManager.Shutdown(); Application.Current.Dispatcher.Invoke(new Action(() => { Application.Current.MainWindow = null; if (LobbyClient != null) { LobbyClient.Stop(); } try { if (WindowManager.DebugWindow != null) { if (WindowManager.DebugWindow.IsLoaded) { WindowManager.DebugWindow.Close(); } } } catch (Exception e) { Debug.WriteLine(e); if (Debugger.IsAttached) { Debugger.Break(); } } try { foreach (var w in WindowManager.ChatWindows.ToArray()) { try { if (w.IsLoaded) { w.CloseDown(); } w.Dispose(); } catch (Exception e) { Log.Warn("Close chat window error", e); } } WindowManager.ChatWindows = new ConcurrentBag <ChatWindow>(); } catch (Exception e) { Log.Warn("Close chat window enumerate error", e); } if (WindowManager.PlayWindow != null) { if (WindowManager.PlayWindow.IsLoaded) { WindowManager.PlayWindow.Close(); } } //Apparently this can be null sometimes? if (Application.Current != null) { Application.Current.Shutdown(0); } })); }