C# 使用Mutex只有一个进程
时间:2019-01-28 13:11:56
收藏:0
阅读:311
使用Mutex只有一个进程
代码
static void Main() { bool createdNew; using(Mutex mutex=new Mutex(true,Application.ProductName,out createdNew)) { if (createdNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } else { MessageBox.Show("Only One Instance is allowed"); System.Environment.Exit(1); } } }
原文:https://www.cnblogs.com/legion/p/10329586.html
评论(0)