请教Thread问题
using   System; 
 using   System.Collections.Generic; 
 using   System.ComponentModel; 
 using   System.Data; 
 using   System.Drawing; 
 using   System.Text; 
 using   System.Windows.Forms; 
 using   System.Threading;   
 namespace   _1 
 { 
             public   partial   class   Form1   :   Form 
             { 
                         public   Form1() 
                         { 
                                     InitializeComponent(); 
                                     x(); 
                         } 
                         int   a=0; 
                         public   void   B() 
                         { 
                                     a++; 
                                     listBox1.Items.Add(a); 
                                     Thread.Sleep(1000); 
                         }   
                      public   void   x() 
                         { 
                                     Thread   t   =   new   Thread(new   ThreadStart(B)); 
                                     t.IsBackground   =   true; 
                                     t.Start(); 
                         } 
             } 
 }   
 运行后 
 1   
 Thread.Sleep(1000)不应该是1秒运行一次么?为什么只显示一个1呢?
------解决方案--------------------加了for才能循环,你的线程就执行了一次 B()   
 最好建立一个委托,在委托中通过for让B()执行多次,输出多个数字
------解决方案--------------------public void demo() 
 { 
 MethodInvoker me = new MethodInvoker(B); 
                 for (int i = 0; i  < 20; i++) 
                 { 
                     this.BeginInvoke(me); 
                     Thread.Sleep(1000); 
                 } 
 }   
         int a=0; 
         public void B() 
         { 
             a++; 
             listBox1.Items.Add(a); 
         }   
        public void x() 
         { 
             Thread t = new Thread(new ThreadStart(demo)); 
             t.IsBackground = true; 
             t.Start(); 
         }     
 //改成这样子,你再试试,这个是执行20次的 
 //你的代码在vs05中无法通过,子线程操控了UI线程创建的控件,vs03可以通过