标签文字在线程睡眠前不会改变?

时间:2016-03-24 11:33:39

标签: c# label

我试图更改我的标签文本,然后在下一个表单打开之前有一个延迟。但是标签文字不会改变而只是等待?

label3.Text = "loading tools";
        Thread.Sleep(2000);
        Form4 frm = new Form4();
        frm.Show();
        this.Hide();

2 个答案:

答案 0 :(得分:0)

更改标签文本后添加Application.DoEvents():

label3.Text = "loading tools";
Application.DoEvents();
Thread.Sleep(2000);
Form4 frm = new Form4();
frm.Show();
this.Hide();

答案 1 :(得分:0)

label3.Text =“loading tools”;

label3.Refresh();

Thread.sleep代码(2000);

Form4 frm = new Form4();

frm.Show();

this.Hide();

相关问题