In general, such a problem, tied the beginning of the cycle to a button in the usual way.
for (i = 0; i <= 50; ++i) { Thread.Sleep(100); label.Content = i.ToString(); } But the label is updated only when the cycle reaches the final number - 50, how to make 1, 2, 3, 4 successively rewritten to the label ... and so on. The progress bar should also be filled.
But if I deal with the label, then the progress bar can also be finalized.