Boolean createdNew; //返回是否赋予了使用线程的互斥体初始所属权
System.Threading.Mutex instance = new System.Threading.Mutex(true"MutexName"out createdNew); //同步基元变量
if (createdNew) //赋予了线程初始所属权,也就是首次使用互斥体
{
    Application.Run(
new Form1()); /s/这句是系统自动写的
    instance.ReleaseMutex();
}
else
{
    MessageBox.Show(
"已经启动了一个程序,请先退出!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
    Application.Exit();
}

相关文章:

  • 2021-10-30
  • 2021-06-29
  • 2022-01-20
  • 2021-12-16
  • 2022-02-14
  • 2022-12-23
猜你喜欢
  • 2021-09-29
  • 2021-08-03
  • 2021-07-31
  • 2021-07-02
相关资源
相似解决方案