My app is forced to use a 3rd party module which will blue-screen Windows if two instances are started at the same time on the same machine. To work around the issue, my C# app has a mutex:
static Mutex mutex = new Mutex(true, "{MyApp_b9d19f99-b83e-4755-9b11-d204dbd6d096}");
And I check if it's present - and if so I show an error message and close the app:
bool IsAnotherInstanceRunning()
{
if (mutex.WaitOne(TimeSpan.Zero, true))
return (true);
else
return (false);
}
The problem is if two users can log in and open the application at the same time, and IsAnotherInstanceRunning() will return false.
How do I get around this?