I'm trying to set a mutex in order to allow running my application in one instance only. I wrote the next code (like suggested here in other post)
public partial class App : Application
{
private static string appGuid = "c0a76b5a-12ab-45c5-b9d9-d693faa6e7b9";
protected override void OnStartup(StartupEventArgs e)
{
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid))
{
if (!mutex.WaitOne(0, false))
{
MessageBox.Show("Instance already running");
return;
}
base.OnStartup(e);
//run application code
}
}
}
Regretfully this code isn't working. I can launch my application in multiple instances. Is anyone has an idea what is wrong in my code? Thanks