protected override void OnStartup(StartupEventArgs e)
{
var mutex = new Mutex(true, "AsyncApp");
if (!mutex.WaitOne(TimeSpan.Zero, true))
{
MessageBox.Show("程序已存在");
Environment.Exit(0);
return;
}
base.OnStartup(e);
}
WPF使用互斥锁Mutex实现程序启动唯一实例
最新推荐文章于 2024-04-09 16:22:56 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)