日期:2014-05-19  浏览次数:20889 次

多线程访问窗体控件出错
哪位老师教我!谢谢!            


delegate   void   SetTextCallback1(string   test);
                public   void   TestClass(string   test)
                {
                        if   (this.textBox2.InvokeRequired)
                        {
                                SetTextCallback1   a   =   new   SetTextCallback1(TestClass);
                                this.Invoke(a,   new   object[]   {   test   });
                        }
                        else
                        {
                                for   (int   i   =   0;   i   <   100;   i++)
                                {
                                        this.textBox2.Text   +=test+   "\r\n ";    
                                }
                               
                        }
                }
                public   void   TestClass1()
                {
                        if   (this.textBox1.InvokeRequired)
                        {
                                SetTextCallback   d   =   new   SetTextCallback(TestClass1);
                                this.Invoke(d,   new   object[]   {});
                        }
                        else
                        {
                                for   (int   i   =   0;   i   <   500;   i++)
                                {