I do this:
clear();
coinRefundComplete.Visible = true;
state = 0;
System.Threading.Thread.Sleep(4000);
clear();
greeting.Visible = true;
rate.Visible = true;
refundTicket.Visible = true;
currentTime.Visible = true;
我希望"coinRefundComplete"文字(它是一个标签)会出现4秒钟,然后被我用clear()方法清除,然后发生一些其他的事情。但是,当我用第一个clear()清除表单后,我的表单会在4秒钟内变成空白,然后正常结束。
System.Threading.Thread.Sleep(4000);
之前插入Application.DoEvents();
- 给 UI 一个机会来 重绘 标签。 - Dmitry BychenkoApplication.DoEvents()
很糟糕。和在UI线程上调用Thread.Sleep(...)
一样糟糕,甚至更糟。 - Enigmativity