Cavey <Ca***@discussions.microsoft.comwrote:
Encountering a issue where I define a mutex to enforce a single instance of
an application. It works well under Debug but switching to release it fails
everytime..
bool exclusive = false;
Mutex m = new Mutex(true, "SOEIFrameworkMutex", out exclusive);
if (exclusive)
{
// run app
}
else
{
// lookup exisitng process and bring to the fore
}
Any ideas on what could cause this are most appreciated
Your mutex is being garbage collected. Either assign it to a static
variable, or put a "using" statement around the main code:
bool exclusive = false;
using (Mutex = new Mutex(true, "SOEIFrameworkMutex", out exclusive))
{
if (exclusive)
{
// run app
}
else
{
// lookup exisitng process and bring to the fore
}
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too