如何只保证窗口只打开一次[即只运行一个进程]

参考文章:

http://blog.csdn.net/xwdpepsi/article/details/6614248

protected override void OnStartup(StartupEventArgs e)
{
bool isRuned;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OnlyRunOneInstance", out isRuned);//判断是否已存在
if (isRuned)
{
base.OnStartup(e);
this.ShutdownMode = ShutdownMode.OnMainWindowClose;
var starter = new AppStarer();
starter.Start();
}
else
{
MessageBox.Show("程序已启动!", "提示");
}
}

原文地址:https://www.cnblogs.com/sportdog/p/8350163.html