There is a code in which the progress bar is filled, reaching the limit is moving backwards.
private async void btn1_Click(object sender, RoutedEventArgs e) { int i; for (i = 0; i <= 500; ++i) { await Task.Delay(5); label.Content = i.ToString(); pg1.Value = i; } if (pg1.Value == 500) { for (i = 500; i >= 0; --i) { await Task.Delay(5); label.Content = i.ToString(); pg1.Value = i; } } } In general, how to create a stop emulation is understandable, for example:
Task.Delay(5000000) So, how to use the second handler to pause !! instead of completing the cycle and, accordingly, completing the task (filling the progress bar), then resuming it if necessary, that is, there are no problems with stopping, but then how to start the cycle from the current value so that the countdown continues after the task (cycle) is paused.
Currentproperty and change it in the same loop. Next time just start with it. - user227049