Mercurial > servermonitor
view ServerMonitor/Program.cs @ 5:b6fe203af9d5
Private key passwords and validation
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Thu, 28 Feb 2019 21:19:32 -0500 |
parents | 3e1a2131f897 |
children | 052aa62cb42a |
line wrap: on
line source
using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Windows.Forms; namespace ServerMonitorApp { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ServerSummaryForm()); } static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { //if (!System.Diagnostics.Debugger.IsAttached) ShowError(e.Exception); } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { //if (!System.Diagnostics.Debugger.IsAttached) ShowError(e.ExceptionObject as Exception); } static void ShowError(Exception e) { string simpleStackTrace = string.Join(Environment.NewLine, new System.Diagnostics.StackTrace(e).GetFrames() .Select(f => f.GetMethod().DeclaringType.Name + "." + f.GetMethod().Name).ToArray()); MessageBox.Show(e.Message + Environment.NewLine + Environment.NewLine + simpleStackTrace, "Server Monitor Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }