【发布时间】:2013-12-17 20:56:25
【问题描述】:
我有一个 WPF 应用程序,我想在屏幕上显示某些信息之前先睡一秒钟。所以是。 1. 点击一个按钮。
- 睡眠 1 秒。
- 显示标签。
- 睡眠 1 秒。
- 显示标签。
-
等等等等
private void RunTest() { clearTable(); System.Threading.Thread.Sleep(1000); this.Cursor = Cursors.Wait; Label_OS_Result.Content = operatingSystem; Image_OS.Visibility = Visibility.Visible; System.Threading.Thread.Sleep(1000); Label_CPU_Result.Content = procName; Image_CPU.Visibility = Visibility.Visible; System.Threading.Thread.Sleep(1000); }
但是当我点击我的按钮时,它似乎会等待几秒钟,然后一次显示所有内容。
这是怎么回事??
【问题讨论】:
-
这就是计时器的用途。看看 DispatcherTimer。
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。