我不懂 Thread.Sleep(1000);
再BUTTON事件里                 
button1.Text = "d";
Thread.Sleep(1000);
button1.Text = "e";永远Thread.Sleep(1000);这句先执行。再D和E。。
那Thread.Sleep(1000)还有什么意义??
我想先执行
            button1.Text = "d";暂停1秒后再执行
             button1.Text = "e";
怎么实现呢??

解决方案 »

  1.   

    button1.Text = "d"; 
    Thread.Sleep(1000); 
    button1.Text = "e"; 
    Thread.Sleep(1000); //绝对不会先执行
    button1.Text = "d"; 
    Thread.Sleep(1000); 你暂停的线程是你当前窗口的主线程所以当你暂停的时候窗口的一切活动都会终止 包括消息和重新绘制都全部终止 所以你看不到button1.Text = "d"; 的效果 你可以调试代码看代码肯定button1.Text = "e"; 先执行
      

  2.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;namespace oop
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                this.timer1.Start();
            }        private void timer1_Tick(object sender, EventArgs e)
            {
                this.textBox1.Text = "D";
                this.timer1.Enabled = false;
                this.timer2.Start();
            }        private void timer2_Tick(object sender, EventArgs e)
            {
                this.textBox1.Text = "E";
                this.timer2.Enabled = false;
                this.timer1.Start();
            }
        }
    }这样实现  用两个timer很简单~  如果想用一个实现的话`可以用委拖
      

  3.   

    是不是窗体单线程,一sleep,改变了也显示不出来?
      

  4.   

    所以我想先button2.Text = "d";这个效果先出来。。再SLEEP啊。。
    我知道它先执行的。。
    但老是先SLEEP啊
      

  5.   

    button1.Text = "d"; 
    Thread.Sleep(1000); 
    Application.DoEvents();
    button1.Text = "e"; 
      

  6.   

    光有start(),没有停止地方法啊