Beispiel #1
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();
                }
            }
        }
Beispiel #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();
        }
Beispiel #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();
            }
        }
Beispiel #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();
        }