[C#] 应用互斥锁/防双开

            System.Threading.Mutex mutex = new System.Threading.Mutex(false, "CottonGating");
            bool Running = !mutex.WaitOne(0, false);
            if (!Running)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
            else
            {
                MessageBox.Show("程序已启动!");
            }

使用Mutex来防止应用双开

posted @ 2023-06-21 16:23  sssfffsssfff  阅读(62)  评论(0)    收藏  举报