static void Main() { if (!SingleInstance.Start()) { return; } // Mutex not obtained so exit Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { var applicationContext = new CustomApplicationContext(); Application.Run(applicationContext); } catch (Exception ex) { // ReSharper disable LocalizableElement MessageBox.Show(ex.Message, "Program Terminated Unexpectedly", MessageBoxButtons.OK, MessageBoxIcon.Error); // ReSharper restore LocalizableElement } SingleInstance.Stop(); // All finished so release the mutex }
/// <summary> /// Creates a hotkey manager and captures the application context. /// </summary> /// <param name="applicationContext">Application context.</param> public HotkeyManager(CustomApplicationContext applicationContext) { _applicationContext = applicationContext; CreateHandle(new CreateParams()); }