public Login(Main main) { InitializeComponent(); _main = main; _main.materialSkinManager.AddFormToManage(this); if (silentStart) System.Threading.Thread.Sleep(1000); _setting = new Setting(this); notes = new Notes[10]; noteCount = Properties.Settings.Default.NoteCount; if (Properties.Settings.Default.RequiredPassword == false) { if (noteCount == 0) { newNote(); } else { int i; if (silentStart) System.Threading.Thread.Sleep(3000); for (i = 0; i < noteCount; i++) { createNote(i); } } } else Visible = true; }
static void Main(string[] args) { do { Debug.WriteLine(" " + timeRetry.ToString()); try { if (mutex.WaitOne(TimeSpan.Zero, true)) { NoMutexException = false; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (Properties.Settings.Default.UpdateSettingsRequired) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.UpdateSettingsRequired = false; Properties.Settings.Default.Save(); } foreach (string arg in args) { if (arg.ToUpper() == "-SILENTSTART") silentStart = true; } _main = new Main(); Application.Run(_main); mutex.ReleaseMutex(); } else { NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST, NativeMethods.WM_SHOWME, IntPtr.Zero, IntPtr.Zero); } } catch (AbandonedMutexException exc) { NoMutexException = true; Debug.WriteLine("\n***** ***** ***** Found an AbandonedMutexException. Retry now... \n"); mutex.ReleaseMutex(); timeRetry--; } } while (NoMutexException && timeRetry > 0); }