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/p/2410795.html