I have a console application in C# and I want to restrict my application to run only one instance at a time.It's work fine in one system.When i try to run the exe in another system it's not working.The problem is In one pc i can open only one exe. When i try to run on another pc i can open more than one exe.How can i resolve this issue? Below are the code i have written.
string mutexId = Application.ProductName;
using (var mutex = new Mutex(false, mutexId))
{
if (!mutex.WaitOne(0, false))
{
MessageBox.Show("Instance Already Running!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return;
}
//Remaining Code here
}