private static void SingleInstanceCallback(object sender, InstanceCallbackEventArgs args) { if (WaitFormLoad(5000)) { Action d = () => { if (args.CommandLineArgs == null || args.CommandLineArgs.Length <= 1) { if (MainForm.niTray != null && MainForm.niTray.Visible) { // Workaround for Windows startup tray icon bug MainForm.niTray.Visible = false; MainForm.niTray.Visible = true; } MainForm.ShowActivate(); } else if (MainForm.Visible) { MainForm.ShowActivate(); } MainForm.UseCommandLineArgs(args.CommandLineArgs); }; MainForm.InvokeSafe(d); } }
private static void WaitFormLoad(string[] args) { try { if (MainForm.ReadyWaitHandle.WaitOne(5000)) { MainForm.InvokeSafe(() => DoStartupNextInstance(args)); } } catch { } }