winForm 只运行一个实例

 static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            log4net.Config.XmlConfigurator.Configure();
            

            bool flag = false;
            System.Threading.Mutex mutex = new System.Threading.Mutex(true, "ItoMap.UPGIS.UI", out flag);
            if (flag)
            {

                Application.Run(new MainFrm());
                
            }
            else
            {
                MessageBox.Show("系统已经运行!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }

        }
    }
posted @ 2011-06-27 12:42  千禧牛  阅读(241)  评论(0)    收藏  举报