public static void Main(params string[] args) { if (args.Length > 0 && args[1] == "/update" && !OnlineUpdate.HandleUpdateArgs(args)) { return; } // ReSharper disable once ObjectCreationAsStatement using (_ = new Mutex(true, Application.ProductName, out bool createdNew)) { if (createdNew) { Run(args); return; } RunWithArgs(args); } }
public static void Main(params string[] args) { if (args.Length > 0 && !OnlineUpdate.HandleUpdateArgs(args)) { return; } bool createdNew; // ReSharper disable once ObjectCreationAsStatement new Mutex(true, Application.ProductName, out createdNew); if (!createdNew) { return; } // 绑定异常捕捉处理函数 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += (sender, e) => { Util.ShowBugReportForm(e.Exception); }; AppDomain.CurrentDomain.UnhandledException += (sender, e) => { if (e.IsTerminating) { } Util.ShowBugReportForm((Exception)e.ExceptionObject); }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Application.Run(new MainForm()); } catch (ObjectDisposedException) { // ignore } }