I want the program dose not run again when it is already running.
the codes are working when i use debugging mode, but are not working with when it release.
the codes as below.
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string mtxName = "test mutex";
Mutex mtx = new Mutex(true, mtxName);
TimeSpan tsWait = new TimeSpan(0, 0, 1);
bool success = mtx.WaitOne(tsWait);
if (!success)
{
MessageBox.Show("is running.");
return;
}
Application.Run(new Form1());