使用互斥体Mutex类型

using System.Threading;

//声明互斥体
Mutex mutex = new Mutex(false, "ThisShouldOnlyRunOnce");
//判断互斥体是否使用中
bool Running = !mutex.WaitOne(0, false);
if (!Running)
     Application.Run(new Form1());
else
      MessageBox.Show("应用程序已经启动!");

相关文章: