- using (Mutex mutex = new Mutex(false, "mutex name"))
- {
- if (!mutex.WaitOne(0, true))
- {
- System.Threading.Thread.Sleep(5000);
- MessageBox.Show("Unable to run multiple instances of this program.",
- "Error",
- MessageBoxButtons.OK,
- MessageBoxIcon.Error);
- }
- else
- {
- System.Threading.Thread.Sleep(5000);
- MessageBox.Show("first click");
- //Application.EnableVisualStyles();
- //Application.SetCompatibleTextRenderingDefault(false);
- //Application.Run(new MainForm());
}
Multiple instance detect in windows application.
