/// <summary> /// Creates a global mutex and keeps a static reference to it. This method can be used to /// create a mutex to easily synchronise with a setup. /// </summary> /// <param name="name">The name of the mutex to create in the Global namespace.</param> public static void Create(string name) { if (instance != null) throw new InvalidOperationException("The static global mutex is already created."); // Create a new mutex and keep a reference to it so it won't be GC'ed instance = new GlobalMutex(name); // Close the mutex when the application exits AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; }
/// <summary> /// Creates a global mutex and keeps a static reference to it. This method can be used to /// create a mutex to easily synchronise with a setup. /// </summary> /// <param name="name">The name of the mutex to create in the Global namespace.</param> public static void Create(string name) { if (instance != null) { throw new InvalidOperationException("The static global mutex is already created."); } // Create a new mutex and keep a reference to it so it won't be GC'ed instance = new GlobalMutex(name); // Close the mutex when the application exits AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; }