Пример #1
0
        private static void HandleClosed()
        {
            if (m_Closing)
            {
                return;
            }

            m_Closing = true;

            Console.Write("Exiting...");

            if (!m_Crashed)
            {
                EventSink.InvokeShutdown(new ShutdownEventArgs());
            }

            if (SocketPool.Created)
            {
                SocketPool.Destroy();
            }

            Timer.TimerThread.Set();

            Console.WriteLine("done");
        }
Пример #2
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = e.ExceptionObject as Exception;

            CConsole.Write(EConsoleColor.Error, e.IsTerminating ? "Error: " : "Warning: ");
            CConsole.WriteLine(EConsoleColor.Error, ex.Message);
            if (ex.StackTrace != string.Empty)
            {
                CConsole.WriteLine(ex.StackTrace);
            }

            if (e.IsTerminating)
            {
                mCrashed = true;
                bool close = false;
                try {
                    CrashedEventArgs args = new CrashedEventArgs(e.ExceptionObject as Exception);
                    Events.InvokeCrashed(args);
                    close = args.Close;
                } catch {
                }

                if (!close)
                {
                    SocketPool.Destroy();

                    CConsole.ErrorLine("This exception is fatal, press return to exit");
                    CConsole.Read();
                }

                mClosing = true;
            }
        }
Пример #3
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Console.WriteLine(e.IsTerminating ? "Error:" : "Warning:");
            Console.WriteLine(e.ExceptionObject);

            if (e.IsTerminating)
            {
                m_Crashed = true;

                bool close = false;

                try
                {
                    CrashedEventArgs args = new CrashedEventArgs(e.ExceptionObject as Exception);

                    EventSink.InvokeCrashed(args);

                    close = args.Close;
                }
                catch
                {
                }

                if (!close && !m_Service)
                {
                    try
                    {
                        for (int i = 0; i < m_MessagePump.Listeners.Length; i++)
                        {
                            m_MessagePump.Listeners[i].Dispose();
                        }
                    }
                    catch
                    {
                    }

                    if (SocketPool.Created)
                    {
                        SocketPool.Destroy();
                    }

                    if (m_Service)
                    {
                        Console.WriteLine("This exception is fatal.");
                    }
                    else
                    {
                        Console.WriteLine("This exception is fatal, press return to exit");
                        Console.ReadLine();
                    }
                }

                m_Closing = true;
            }
        }
Пример #4
0
        private static void HandleClosed()
        {
            if (mClosing)
            {
                return;
            }

            if (!mCrashed)
            {
                Events.InvokeShutdown(new ShutdownEventArgs());
            }

            mClosing = true;
            CConsole.StatusLine("Exiting...");

            // do some kills
            SocketPool.Destroy();

            CConsole.StatusLine("Exiting finished! Press any Key to close.");
        }