日期:2014-05-18 浏览次数:21343 次
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            A a= new A();
            if (a.ShowDialog() == DialogResult.OK)
            {
                Application.Run(new C());
            }
            else
            {
                B b= new B();      
                if (b.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(new C());
                }
            }
delegate void RegCheckCallBack();
 public InitForm()
        {
            InitializeComponent();
            MyInit();
        }
        public void MyInit()
        {
            #region 解决“当初始化时候切换窗口会抛出 线程间操作无效 的错误”
            //Control.CheckForIllegalCrossThreadCalls = false; //最简单方法 进行非安全线程访问时,运行环境就不去检验它是否是线程安全的
            #endregion
            ThreadStart threadStart = new ThreadStart(RegCheck);//通过ThreadStart委托执行注册检测
            Thread thread = new Thread(threadStart);
            thread.Start(); 
        }
        private void RegCheck()
       {
            if (this.InvokeRequired)
            {
                RegCheckCallBack rccb = new RegCheckCallBack(RegCheck);
                this.Invoke(rccb);
            }
            else
            {
                bool chkResult = Bll.check();
                if (chkResult)
                {
                    this.DialogResult = DialogResult.OK;
                    C c = new C();
                    c.Show();
                    this.Visible = false;
                }
                else
                {
                    this.DialogResult = DialogResult.No;
                    B b = new B();
                    b.Show();
                    this.Visible = false;
                }
            }
        }