zoukankan      html  css  js  c++  java
  • winform 捕获并处理未处理的异常

        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(AppThreadException);
                Application.Run(new sqlToXMLtool());
            }

            private static void AppThreadException(object source, System.Threading.ThreadExceptionEventArgs e)
            {
                string errorMsg = string.Format("未处理异常: \n{0}\n", e.Exception.Message);
                errorMsg += Environment.NewLine;

                DialogResult result = MessageBox.Show(errorMsg, "Application Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop);

                //如果点击“中止”则退出程序
                if (result == DialogResult.Abort)
                {
                    Application.Exit();
                }
            }
        }

  • 相关阅读:
    剑指Offer对答如流系列
    剑指Offer对答如流系列
    KMP算法
    殊途同归
    从m个数中取top n
    用红黑树实现500万数据的动态排序
    返璞归真
    second blog编程之美------控制cpu曲线
    first blog编程之美-----计算1的个数
    mathematica入门学习记录:
  • 原文地址:https://www.cnblogs.com/wangjingblogs/p/9527_wangjing.html
Copyright © 2011-2022 走看看