private void RunTimerBackwords() { timerRunTask = Task.Run(() => { if (!tokenSource.IsCancellationRequested) { for (int i = 30; i >= 0; i--) { TimerCountDown.Result = i.ToString(); Thread.Sleep(1000); if (tokenSource.IsCancellationRequested) { break; } } if (!tokenSource.IsCancellationRequested) { RightAnswer = false; WrongAnswer = false; MyCommand_OptionWrong.RaiseCanExecuteChanged(); MyCommand_OptionRight.RaiseCanExecuteChanged(); } } }, tokenSource.Token); }
public void ExecuteMethod_Wrong() { tokenSource.Cancel(); //disable buttons RightAnswer = false; WrongAnswer = false; MyCommand_OptionWrong.RaiseCanExecuteChanged(); MyCommand_OptionRight.RaiseCanExecuteChanged(); TimerCountDown.WinColor = new SolidColorBrush(Colors.LightPink); }