winform中调用主线程控件的方法

今天做的一个小东西,tcp/ip的数据传输问题,把子线程的值传递到主线程的空间中显示

 

可以使用委托实现

      public  delegate void MainC(bool a ,bool b,string URLStr);
      

        public void mainCtr(bool a,bool b,string URLStr)
        {
            this.webBrowser1.Visible = a;
            this.pictureBox1.Visible = b;
            this.webBrowser1.Url = new Uri(@"http://" + URLStr);
        }

 

 

子线程代码

      MainC deleMain = new MainC(mainCtr);

      this.Invoke(deleMain, true, false, URLStr);

 

 

 

posted @ 2012-08-01 14:24  尼姑哪里跑  阅读(390)  评论(0编辑  收藏  举报