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;
}

 

posted @ 2012-03-21 23:11  ghypnus  阅读(429)  评论(0编辑  收藏  举报