I am trying to install a mutex to allow my application to run in only one instance. I wrote the following code (for example, suggested here in another 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);
Unfortunately, this code does not work. I can run the application in multiple instances. Does anyone have an idea of ββwhat's wrong with my code? Thanks
source share