using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using DevExpress.UserSkins; using DevExpress.Skins; using DevExpress.LookAndFeel; using System.Threading; using Lskj.Control; using Lskj.Util; namespace CensorModule { static class Program { /// /// 是否退出应用程序 /// static bool glExitApp = false; /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); BonusSkins.Register(); SkinManager.EnableFormSkins(); UserLookAndFeel.Default.SetSkinStyle("DevExpress Style"); //处理未捕获的异常 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //处理非UI线程异常 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.Run(new FrmMain()); glExitApp = true;//标志应用程序可以退出 } /// /// 说明:处理异常 /// 创建人:龚宇超 /// 创建日期:2017-11-22 /// 修改人: /// 修改日期: /// 修改备注: /// 版本:1.0 /// /// The source of the event. /// The instance containing the event data. static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { MessageUtil.Show(e.Exception); LogHelper.Instance.WriteError(e.Exception); } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { MessageUtil.Show(e.ExceptionObject.ToString()); while (true) {//循环处理,否则应用程序将会退出 if (glExitApp) {//标志应用程序可以退出,否则程序退出后,进程仍然在运行 MessageUtil.Show(e.ExceptionObject.ToString()); return; } System.Threading.Thread.Sleep(2 * 1000); }; } } }