I have created simple MutexManager:
public static class MutexManager
{
private static string mutexName
{
get
{
return "MyAppName" + System.Security.Principal.WindowsIdentity.GetCurrent().User.AccountDomainSid;
}
}
public static bool CreateApplicationMutex()
{
bool createdNew;
var mutex = new Mutex(false, mutexName, out createdNew);
return createdNew;
}
}
The problem is that CreateApplicationMutex always returns true on new application instance startup. As long as I had exactly same code in app.cs everything was correct, but after I moved it to MutexManager createdNew is always true. What am I doing wrong?