zoukankan      html  css  js  c++  java
  • 多线程操作控件C#

    不要在创建控件以外的线程操作控件,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));  
      }
  • 相关阅读:
    每日总结
    每日总结
    每日总结
    每日总结
    每日总结
    每日总结
    每日总结
    每日总结
    团队博客
    团队博客
  • 原文地址:https://www.cnblogs.com/yeagen/p/1350785.html
Copyright © 2011-2022 走看看