private void RunTimerBackwords() { timerRunTask = Task.Run(() => { if (!tokenSource.IsCancellationRequested) { for (int i = 30; i >= 0; i--) { Result = i.ToString(); Thread.Sleep(1000); if (tokenSource.IsCancellationRequested) { break; } } if (!tokenSource.IsCancellationRequested) { CorrectAnswer = false; WrongAnswer = false; MyCommandOptionWrong.RaiseCanExecuteChanged(); MyCommandOptionCorrect.RaiseCanExecuteChanged(); } } }, tokenSource.Token); }
public void ExecuteMethod_Wrong() { tokenSource.Cancel(); CorrectAnswer = false; WrongAnswer = false; MyCommandOptionWrong.RaiseCanExecuteChanged(); MyCommandOptionCorrect.RaiseCanExecuteChanged(); Color = new SolidColorBrush(Colors.LightPink); }