保证该程序只有一个在运行

 //保证该程序只有一个在运行
            bool createdNew;
            System.Threading.Mutex mutex_Application = new System.Threading.Mutex(true, "Robot", out createdNew);
            if (!createdNew)
            {
                MessageBox.Show("本程序只允许同时运行一个!");
                return;
            }

            Login Lrm = new Login();
            if (DialogResult.OK == Lrm.ShowDialog())
            {
                Mywork MyMainForm = new Mywork();
                Application.Run(MyMainForm);
            }
            else
            {
                Application.Exit();
            }

posted @ 2007-11-27 16:28  RobotTech  阅读(247)  评论(0编辑  收藏  举报