I want to update a progress bar from running 1 to 100 with this code.
for (int i = 0; i <= 100; i++) {
System.Threading.Thread.Sleep(100);
progressBar1.Value = i;
}
But the result is, the UI freeze until looping finish.
I know Dispatcher
can help, but I don't want to split function.
Is there any command to update UI immediately like..
for (int i = 0; i <= 100; i++) {
System.Threading.Thread.Sleep(100);
progressBar1.Value = i;
UpdateUINow();
}
Edit: I'm using WPF, and I use Thread.Sleep to simulate long running process.
In fact, I want any command liked Application.DoEvents
. But I cannot find this command in WPF.