static public void Run(ITunesHandler handler, Form mainForm, string[] commandLine) { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); StartupNextInstanceEventHandler startupNextInstanceEventHandler = new StartupNextInstanceEventHandler(app_StartupNextInstance); ShutdownEventHandler shutdownEventHandler = new ShutdownEventHandler(app_Shutdown); SingleInstanceApplication.Run(mainForm, commandLine, startupNextInstanceEventHandler, shutdownEventHandler); }
public static void Run(Form mainForm, string[] commandLine, StartupNextInstanceEventHandler startUpNextInstanceEventHandler, ShutdownEventHandler shutdownEventHandler) { SingleInstanceApplication app = new SingleInstanceApplication(); if (startUpNextInstanceEventHandler != null) app.StartupNextInstance += startUpNextInstanceEventHandler; if (shutdownEventHandler != null) app.Shutdown += shutdownEventHandler; if (mainForm != null) app.MainForm = mainForm; app.Run(commandLine); app.OnShutdown(); }
static void app_StartupNextInstance(object sender, Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs e) { SingleInstanceApplication app = (SingleInstanceApplication)sender; Form mainForm = (Form)app.MainForm; if (mainForm != null) { mainForm.Show(); } }
static void app_Shutdown(object sender, EventArgs e) { try { SingleInstanceApplication app = (SingleInstanceApplication)sender; Form mainForm = (Form)app.MainForm; if (mainForm != null) { mainForm.Close(); } } catch { } }
public static void Run(Form mainForm, string[] commandLine, StartupNextInstanceEventHandler startUpNextInstanceEventHandler, ShutdownEventHandler shutdownEventHandler) { SingleInstanceApplication app = new SingleInstanceApplication(); if (startUpNextInstanceEventHandler != null) { app.StartupNextInstance += startUpNextInstanceEventHandler; } if (shutdownEventHandler != null) { app.Shutdown += shutdownEventHandler; } if (mainForm != null) { app.MainForm = mainForm; } app.Run(commandLine); app.OnShutdown(); }