winform 防止奔溃重启

Posted on 2016-03-03 17:41  霍先生的博客  阅读(319)  评论(0编辑  收藏  举报
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new MsgMain());
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new form1());
        }
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)     //异常崩溃重启
        {
            Application.Restart();
        } 

 

Copyright © 2024 霍先生的博客
Powered by .NET 8.0 on Kubernetes


 

< img src="" />