Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ui/Features/Translate/AutoTranslateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ private void Ok()
private void Cancel()
{
var wasTranslating = !IsTranslateEnabled;
_cancellationTokenSource.Cancel();
_abort = true;
_cancellationTokenSource.Cancel();
IsProgressEnabled = false;

if (IsTranslateEnabled)
Expand Down Expand Up @@ -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 () =>
Expand Down