/// <summary>Creates and displays the error message.</summary>
        private static DialogResult ShowThreadExceptionDialog(Exception ex)
        {
            var result = DialogResult.Abort;

            var errorMessage =
                "Unhandled Exception:" + NewLineX2 +
                ex.Message + NewLineX2 +
                ex.GetType() + NewLineX2 +
                "Stack Trace:" + NewLine +
                ex.StackTrace;

            using (var dialog = new ExceptionDialog(errorMessage)) {
                dialog.ShowDialog();
                result = dialog.DialogResult;
            }

            return(result);
        }
        /// <summary>Creates and displays the error message.</summary>
        private static DialogResult ShowThreadExceptionDialog(Exception ex)
        {
            var errorMessage =
                "Unhandled Exception:" + Environment.NewLine + Environment.NewLine +
                ex.Message + Environment.NewLine + Environment.NewLine +
                ex.GetType() + Environment.NewLine + Environment.NewLine +
                "Stack Trace:" + Environment.NewLine +
                ex.StackTrace;

            var dialog = new ExceptionDialog(errorMessage);

            try {
                dialog.Show();
            } finally { if (dialog != null)
                        {
                            dialog.Dispose();
                        }
            }
            return(DialogResult.Abort);
        }