private void button1_Click(object sender, EventArgs e)
        {
      
      if (b == false)
            {
                b = true;
                th = new Thread(playgame);
                th.IsBackground = true;
                button1.Text = "停止";
                th.Start();
            }
            else//b=true
            {
                b = false;
                button1.Text = "开始";
            }
        }
        bool b = false;
        private void playgame()
        {
            Random r = new Random();
            while (b)
            {
                label1.Text = r.Next(0, 10).ToString();
                label2.Text = r.Next(0, 10).ToString();
                label3.Text = r.Next(0, 10).ToString();
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            
        }
        Thread th;
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (th != null)
            { th.Abort(); }     
        }
    }
原文:http://www.cnblogs.com/-slient/p/5116631.html