Def*_*igh 4 wpf textbox progress
我有这个代码:
void wait(int ms)
{
System.Threading.Thread.Sleep(ms);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
info.Text = "step 1";
wait(1000);
info.Text = "step 2";
wait(1000);
info.Text = "step 3";
wait(1000);
info.Text = "step 4";
wait(1000);
}
Run Code Online (Sandbox Code Playgroud)
问题是textbox.text在整个void button1_Click完成后更新.它没有在AIR上更新:(
拜托,怎么办?
就这样做吧.
private void button1_Click(object sender, RoutedEventArgs e)
{
ThreadPool.QueueUserWorkItem((o) =>
{
Dispatcher.Invoke((Action) (() => info.Text = "step 1"));
wait(1000);
Dispatcher.Invoke((Action) (() => info.Text = "step 2"));
wait(1000);
Dispatcher.Invoke((Action) (() => info.Text = "step 3"));
wait(1000);
Dispatcher.Invoke((Action) (() => info.Text = "step 4"));
wait(1000);
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9503 次 |
| 最近记录: |