Exemplo n.º 1
0
        private static void ExceptionClose(Exception exception)
        {
            try
            {
                IsUserExit = false;
                Settings.Default.Locked = true;
                String trace = exception.GetStackTrace();

                ServerForm.MainLog.WriteMessage(String.Format("[Exception] {0}", trace), Color.Red);

                MailManager.QueueMail("Server Crash", trace);

                Interval maxMailWait = new Interval(10000, false);
                while (MailManager.HasPendingMail && !maxMailWait.HasElapsed)
                {
                    Thread.Sleep(1);
                }

                ServerForm.PurgeAllLogMessages();
            }
            finally
            {
                Environment.Exit(exception.HResult);
            }
        }