首页 > 应用开发 > IT综合 > C#控制只能程序运行一个
以下代码是使用C#控制只能程序运行一个,不能同时运行两个:
static void Main()
{
bool flag=false;
System.Threading.Mutex mutex=new System.Threading.Mutex(true,"YourMutexName",out flag);
if ( !flag )
{
Application.Exit();
MessageBox.Show("Runing");
return;
}
Application.Run(new frmMain());
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9437124/viewspace-1018098/ ,如需转载,请注明出处,否则将追究法律责任。