I have written code for Progress Bar : Belowprogress is the code but progress bar has to stop when clicking Stop button can anyone help me in this please :
- private void btn_StartLengthyTask_Click(object sender, RoutedEventArgs e)
- {
- pb_LengthyTaskProgress.Value = InitialSleepTime;
- pb_LengthyTaskProgress.Maximum = 100;
- Task.Run(() =>
- {
- for (int i = 0; i < 101; i++)
- {
- this.Dispatcher.Invoke(() =>
- {
- pb_LengthyTaskProgress.Value = i;
- lbl_CountDownTimer.Text = i.ToString();
- });
- Thread.Sleep(ThreadSleepTime) ;
- }
- });
- }