解决方案 »

  1.   

    Random rd = new Random();这个放在函数外面。作为成员变量。
      

  2.   

    caozhy:按您的方法,还是一样的不行呀。
      

  3.   

    bool stopped=false;
    //委托方法
            private void SetText(string text)
            {
                if (this.textBox1.InvokeRequired)
                {
                    SetTextCallback d = new SetTextCallback(SetText);
                    this.Invoke(d, new object[] { text });
                }
                else
                {
                    this.textBox1.Text = text;
    if(stopped)
    {
    this.label2.Text = this.label2.Text + "结果:" + this.textBox1.Text + System.Environment.NewLine;
    }
                }
            }        //停止按钮
            private void button2_Click(object sender, EventArgs e)
            {
    stopped=true;
                this.doYaohao.Abort();            
            }
      
    *****************************************************************************
    签名档: http://feiyun0112.cnblogs.com/
      

  4.   

    在线程启动前,还需要:stopped=true;谢谢 feiyun0112