Skip to content

Commit

Permalink
remove try-catch around CTS.Cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
AmadeusW committed Dec 9, 2024
1 parent 934eb0b commit 7dffaa5
Showing 1 changed file with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,7 @@ private void FetchSuggestions(bool isAutomaticOnInitialization)
}

var listenerToken = _asyncListener.BeginAsyncOperation(nameof(_smartRenameSession.GetSuggestionsAsync));
try
{
_cancellationTokenSource.Cancel();
}
catch { }
_cancellationTokenSource.Cancel();
_cancellationTokenSource = new CancellationTokenSource();
GetSuggestionsTaskAsync(isAutomaticOnInitialization, _cancellationTokenSource.Token).CompletesAsyncOperation(listenerToken);
}
Expand Down Expand Up @@ -315,11 +311,7 @@ private async Task SessionPropertyChangedAsync(object sender, PropertyChangedEve

public void Cancel()
{
try
{
_cancellationTokenSource.Cancel();
}
catch { }
_cancellationTokenSource.Cancel();
// It's needed by editor-side telemetry.
_smartRenameSession.OnCancel();
PostTelemetry(isCommit: false);
Expand All @@ -339,11 +331,7 @@ public void Dispose()
_smartRenameSession.PropertyChanged -= SessionPropertyChanged;
BaseViewModel.PropertyChanged -= BaseViewModelPropertyChanged;
_smartRenameSession.Dispose();
try
{
_cancellationTokenSource.Cancel();
}
catch { }
_cancellationTokenSource.Cancel();
}

/// <summary>
Expand Down Expand Up @@ -385,11 +373,7 @@ private void BaseViewModelPropertyChanged(object sender, PropertyChangedEventArg
if (e.PropertyName == nameof(BaseViewModel.IdentifierText))
{
// User is typing the new identifier name, cancel the ongoing request to get suggestions.
try
{
_cancellationTokenSource.Cancel();
}
catch { }
_cancellationTokenSource.Cancel();
}
}
}

0 comments on commit 7dffaa5

Please sign in to comment.