核心代碼:
public static void OnlyRunOneCheck() { bool isRun; System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out isRun); if (isRun == false) { Mbox.Info("目前已有一個程序在運行,請勿重複運行程序"); Environment.Exit(0); } }
核心代碼:
public static void OnlyRunOneCheck() { bool isRun; System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.ProductName, out isRun); if (isRun == false) { Mbox.Info("目前已有一個程序在運行,請勿重複運行程序"); Environment.Exit(0); } }