C# winform 禁止程序重复运行方法

bool bOnlyOneInstance = false;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, Application.UserAppDataPath.Replace(@"\", "_"), out bOnlyOneInstance);
if (!bOnlyOneInstance)
{
MessageUtil.ShowTips("程序已经运行!");
System.Environment.Exit(0);
return;
}

 

转载于:https://www.cnblogs.com/ghypnus/archive/2012/03/21/2410795.html

你可能感兴趣的:(C# winform 禁止程序重复运行方法)