Hello.
I need to run a windows console application (.NET, C#), but avoidding the execution another instance of the same application at same time.
How to do that?
Printable View
Hello.
I need to run a windows console application (.NET, C#), but avoidding the execution another instance of the same application at same time.
How to do that?
Use System.Process to see if a process from the same executable file exist
Hallo,
try to resolve your problem with this, maybe it'll help you.
r.
try
{
bool firstInstance = false;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out firstInstance);
if(!firstInstance)
{
MessageBox.Show("You cannot run application twice.","Information");
return;
}
Application.Run(new TableForm ());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
Thank you very much!
The mutex solution works perfectly!
I have problem with the above code when running application in release mode?
The firstInstance seems to be true all the time.
Anyone having simular problems?