// Setup a unique Name for your Application static Mutex mutex = new Mutex(false, "My_Unique_App_ID"); /// /// The main entry point for the application. /// [STAThread] static void Main() { // Delay 3 seconds to be sure that there is no other instance running if (!mutex.WaitOne(TimeSpan.FromSeconds(3), false)) { MessageBox.Show("Another instance of this application is already running"); return; } try { // There is no other instances running // Launch the application Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } finally { mutex.ReleaseMutex(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)