I have this code:
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);
}
And problem is that textbox.text is updated after whole void button1_Click finished. It is not updated ON AIR :(
Please, How to do that?
Just do this.
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);
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With