CSharp examples for Thread Asynchronous:Mutex
Ensure That Only One Instance of an Application Can Execute Concurrently
using System;// ww w. j a va 2 s . c o m using System.Threading; class MainClass { public static void Main() { bool ownsMutex; using (Mutex mutex = new Mutex(true, "MutexExample", out ownsMutex)) { if (ownsMutex) { Console.WriteLine("This application currently owns the mutex."); Console.WriteLine("Press any key."); Console.ReadLine(); mutex.ReleaseMutex(); } else { Console.WriteLine("Another instance of this application already owns the mutex named MutexExample. "); } } } }