private static void Main() { AppDomain.CurrentDomain.UnhandledException += ReportAndRestart; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); OptionForm mainForm = new global::ClientApp.OptionForm(); Application.Run(mainForm); }
private static void RunApp(string[] arg) { Process[] processesByName = Process.GetProcessesByName("eAd Client"); if (processesByName.Length <= 1) { Trace.Listeners.Add(new ClientTraceListener()); Trace.AutoFlush = false; try { if (arg.GetLength(0) > 0) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Trace.WriteLine(new LogMessage("Main", "Options Started"), LogType.Info.ToString()); Form mainForm = new global::ClientApp.OptionForm(); Application.Run(mainForm); } else { bool createdNew = true; new Mutex(true, "UniqueApplicationName", out createdNew); if (createdNew) { Splasher.Splash = new SplashScreen(); Splasher.ShowSplash(); Trace.WriteLine(new LogMessage("Main", "Client Started"), LogType.Info.ToString()); new App().Run(); } } } catch (Exception exception) { HandleUnhandledException(exception); } AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Startup.CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(Startup.Application_ThreadException); Trace.WriteLine(new LogMessage("Main", "Application Finished"), LogType.Info.ToString()); Trace.Flush(); } else { ShowWindowAsync(processesByName[0].MainWindowHandle, 6); ShowWindowAsync(processesByName[0].MainWindowHandle, 9); } }