public static void Run(Form f, StartupNextInstanceEventHandler startupHandler) { SingleInstanceApplication app = new SingleInstanceApplication(); app.MainForm = f; app.StartupNextInstance += startupHandler; app.Run(Environment.GetCommandLineArgs()); }
private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frm_Main mainform = new frm_Main(); if (Environment.CommandLine.ToLower().Contains("autoRun".ToLower())) { string address = Path.GetDirectoryName(Application.ExecutablePath); if (address != null) { Process.Start( new ProcessStartInfo(Application.ExecutablePath, "/auto_Corrected_Run") { WorkingDirectory = address, UseShellExecute = true }); } Environment.Exit(0); } if (Environment.CommandLine.ToLower().Contains("auto_Corrected_Run".ToLower())) { mainform.IsAutoRun = true; } try { SingleInstanceApplication.Run(mainform, StartupNextInstanceHandler); } catch (Exception) { Application.Run(mainform); } }
public static void Run(Form f, StartupNextInstanceEventHandler startupHandler) { SingleInstanceApplication app = new SingleInstanceApplication { MainForm = f }; app.StartupNextInstance += startupHandler; app.Run(Environment.GetCommandLineArgs()); }