예제 #1
0
파일: GuiThread.cs 프로젝트: byterj/phoenix
        private void MessagePump(object arg)
        {
            try {
                OnThreadStarted();

                Type windowType = (Type)arg;

                window = (Form)windowType.Assembly.CreateInstance(windowType.FullName);

                MSG m;

                // Create message queue
                PeekMessage(out m, IntPtr.Zero, 0, 0, PM_NOREMOVE);

                // Create window and obtain its handle
                window.CreateControl();
                IntPtr handle = window.Handle;

                // Set created event
                windowCreatedEvent.Set();

                // Message pump
                while (GetMessage(out m, IntPtr.Zero, 0, 0))
                {
                    TranslateMessage(ref m);
                    DispatchMessage(ref m);
                }
            }
            catch (Exception e) {
                FatalExceptionDialog dlg = new FatalExceptionDialog();
                dlg.Exception            = e;
                dlg.TryToContinueEnabled = false;
                dlg.ShowDialog();
                dlg.Dispose();
                Environment.Exit(-1);
            }
            finally {
                // Dispose closed window
                if (window != null)
                {
                    window.Dispose();
                }
            }
        }
예제 #2
0
        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string message;
            if (e.ExceptionObject != null)
                message = "Unhandled exception:\n" + e.ExceptionObject.ToString();
            else
                message = "Undefined unhandled exception occurred in application.";

            Trace.WriteLine(message, "Phoenix");

            if (e.ExceptionObject is Exception) {
                FatalExceptionDialog dlg = new FatalExceptionDialog();
                dlg.Exception = (Exception)e.ExceptionObject;
                dlg.TryToContinueEnabled = !e.IsTerminating;

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    return;
            }
            else {
                System.Windows.Forms.MessageBox.Show(message, "Fatal Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }

            Core.Terminate();
        }
예제 #3
0
        private void MessagePump(object arg)
        {
            try {
                OnThreadStarted();

                Type windowType = (Type)arg;

                window = (Form)windowType.Assembly.CreateInstance(windowType.FullName);

                MSG m;

                // Create message queue
                PeekMessage(out m, IntPtr.Zero, 0, 0, PM_NOREMOVE);

                // Create window and obtain its handle
                window.CreateControl();
                IntPtr handle = window.Handle;

                // Set created event
                windowCreatedEvent.Set();

                // Message pump
                while (GetMessage(out m, IntPtr.Zero, 0, 0)) {
                    TranslateMessage(ref m);
                    DispatchMessage(ref m);
                }
            }
            catch (Exception e) {
                FatalExceptionDialog dlg = new FatalExceptionDialog();
                dlg.Exception = e;
                dlg.TryToContinueEnabled = false;
                dlg.ShowDialog();
                dlg.Dispose();
                Environment.Exit(-1);
            }
            finally {
                // Dispose closed window
                if (window != null)
                    window.Dispose();
            }
        }
예제 #4
0
        private void Exit(Exception e)
        {
            Trace.TraceError(e.ToString());
            Trace.Flush();

            FatalExceptionDialog dlg = new FatalExceptionDialog();
            dlg.Exception = e;

            if (dlg.ShowDialog() != DialogResult.Retry) {
                Core.Terminate();
            }
            else {
                Trace.TraceInformation("Trying to continue.");
                Trace.Flush();
            }

            dlg.Dispose();
        }