想在问号的地方加入一个可变的计时,让计时时间到达后继续for语句的循环            for (; loop != 0; )
            {
                textBox.Text = Convert.ToString(--loop);
                Run(a, b);                ?????????????????????????
                ???????????????????????????????????????               //这个是个错误的
                //System.Threading.Thread thr = System.Threading.Thread.CurrentThread;
               //写5000是为了先学者写简单的(固定计时),
               //再学复杂的(其实最终要求暂停时间可以由用户输入)
               // System.Threading.Thread.Sleep(5000);            }

解决方案 »

  1.   

    用timer控件做吧 那个比较好用
      

  2.   

    for (; loop != 0; )
      {
    ////////此处启动计时t.start();
      textBox.Text = Convert.ToString(--loop);
      Run(a, b);
    ////////此处停止计时t.stop();//T为用户输入时间,t.Interval为计算耗时
        System.Threading.Thread.Sleep(T-t.Interval);
      }
    这样做还是有一定误差的,不过应该可以满足一般的场合了。
      

  3.   

    Random rnd = new Random(DateTime.Now.Millisecond); 
    int i=rnd.Next(min,max);
    System.Threading.Thread.Sleep(i);
      

  4.   

     for (; loop != 0; )
                {
                    textBox5.Text = Convert.ToString(--loop);
                    Run(a, b);
                    //System.Threading.Thread thr = System.Threading.Thread.CurrentThread;
                    if (loop % 2 == 0)
                    {
                        textBox3.ForeColor = System.Drawing.Color.Maroon;
                    }
                    else
                    {
                        textBox3.ForeColor = System.Drawing.Color.Green;
                    }
                    System.Threading.Thread.Sleep(t);
                    Application.DoEvents();
                    //sleep后响应必加.
                }问题出在红色的那一句,嘻嘻,谢谢大家