不要在创建控件以外的线程操作控件,Net   2.0已经把这个作为异常了。可以使用Control的Invoke方法,将操作放到UI线程上。  
  一个简单的例子  
   
  private   void   Form1_Load(object   sender,   System.EventArgs   e)  
  {  
          System.Threading.Thread   tNew   =   new   System.Threading.Thread         (new           System.Threading.ThreadStart(this.Test));  
          tNew.Start();  
  }  
   
  delegate   void   SetVisibleDelegate();  
   
  private   void   SetVisible()   //控件操作  
  {  
        this.button1.Visible   =   true;  
  }  
   
  private   void   Test()  
  {  
        this.Invoke(new   SetVisibleDelegate(SetVisible));  
  }

相关文章:

  • 2022-01-29
  • 2021-06-16
  • 2021-11-24
  • 2022-02-21
  • 2021-10-11
  • 2021-09-27
猜你喜欢
  • 2021-11-29
  • 2022-02-05
  • 2022-01-16
  • 2022-02-12
相关资源
相似解决方案