diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 036ed331e..c3ed2d40e 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1814,7 +1814,12 @@ private BranchTreeNode FindBranchNode(List nodes, string path) private void FetchInBackground(object sender) { - Dispatcher.UIThread.Invoke(async Task () => + Dispatcher.UIThread.Invoke(FetchInBackgroundOnUiThread); + } + + private async Task FetchInBackgroundOnUiThread() + { + try { if (_settings is not { EnableAutoFetch: true }) return; @@ -1856,7 +1861,11 @@ private void FetchInBackground(object sender) _lastFetchTime = DateTime.Now; IsAutoFetching = false; - }); + } + catch (OperationCanceledException) + { + // Ignore cancellation. + } } private readonly bool _isWorktree = false;