private static void Main(string[] args) { // setup unhandled exception handlers Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; WorkPath = Application.StartupPath; if (WorkPath == "") WorkPath = Directory.GetCurrentDirectory(); if (args.Length > 0 && args[0] == "-nogui") { if (args.Length > 1) WorkPath = Utils.Glue(args, 1); GuiEnabled = false; } else if (args.Length > 0) WorkPath = Utils.Glue(args); main = new Main(); if (GuiEnabled) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); } catch (Exception e) { if (!ErrorHandling.HandleException(e, "Application exception")) throw; } } else { if (!main.Start()) return; while (true) Thread.Sleep(5000); } }
public static void Main(string[] args) { // setup unhandled exception handlers if (!Debugger.IsAttached) AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Thread.GetDomain().UnhandledException += Program_UnhandledException; Application.ThreadException += Application_ThreadException; Trace.Listeners.Add(new ConsoleTraceListener()); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var workPath = Application.StartupPath; if (workPath == "") workPath = Directory.GetCurrentDirectory(); main = new Main(workPath); main.UpdateAll(); var selfUpdater = new SelfUpdater("Springie"); var stopProgram = false; selfUpdater.ProgramUpdated += s => { Process.Start(s); stopProgram = true; Environment.Exit(0); }; #if !DEBUG if (!Debugger.IsAttached) selfUpdater.StartChecking(); #endif while (!stopProgram) { Thread.Sleep(5000); try { main.PeriodicCheck(); } catch (Exception ex) {} } }