I want to update the progress bar from 1 to 100 with this code.
for (int i = 0; i <= 100; i++) {
System.Threading.Thread.Sleep(100);
progressBar1.Value = i;
}
But as a result, the UI freezes until the loop ends.
I know it Dispatchercan help, but I don't want to split the function.
Is there any command to update the interface immediately, for example.
for (int i = 0; i <= 100; i++) {
System.Threading.Thread.Sleep(100);
progressBar1.Value = i;
UpdateUINow();
}
Edit: I am using WPF and I am using Thread.Sleep to simulate a lengthy process.
In fact, I want any team to like it Application.DoEvents. But I can not find this command in WPF.
source
share