diff --git a/src/ui/Features/Translate/AutoTranslateViewModel.cs b/src/ui/Features/Translate/AutoTranslateViewModel.cs index 1dcf51e478..2c0c518302 100644 --- a/src/ui/Features/Translate/AutoTranslateViewModel.cs +++ b/src/ui/Features/Translate/AutoTranslateViewModel.cs @@ -627,8 +627,8 @@ private void Ok() private void Cancel() { var wasTranslating = !IsTranslateEnabled; - _cancellationTokenSource.Cancel(); _abort = true; + _cancellationTokenSource.Cancel(); IsProgressEnabled = false; if (IsTranslateEnabled) @@ -1249,6 +1249,12 @@ private async Task DoTranslate(TranslationPair sourceLanguage, TranslationPair t } } + catch (OperationCanceledException) when (_abort || _cancellationTokenSource.IsCancellationRequested) + { + // User pressed Cancel — let the finally block report it; do not surface as an error. + // Check both _abort and the token: Cancel() sets _abort then fires the token, but the + // worker thread can observe cancellation before _abort is visible across threads. + } catch (Exception ex) { _ = Dispatcher.UIThread.Invoke(async () =>