提交 bd97036b 编写于 作者: S Sam Harwell

Remove duplicate calls to ThrowIfCancellationRequested

上级 6137d0eb
......@@ -309,7 +309,6 @@ private void UpdateReferenceLocationsTask(JoinableTask<IInlineRenameLocationSet>
// follow the originally-intended design.
// https://github.com/dotnet/roslyn/issues/40890
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _cancellationTokenSource.Token);
_cancellationTokenSource.Token.ThrowIfCancellationRequested();
RaiseSessionSpansUpdated(inlineRenameLocations.Locations.ToImmutableArray());
......@@ -583,7 +582,6 @@ private void QueueApplyReplacements()
async t =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _conflictResolutionTaskCancellationSource.Token);
_conflictResolutionTaskCancellationSource.Token.ThrowIfCancellationRequested();
ApplyReplacements(t.Result.replacementInfo, t.Result.mergeResult, _conflictResolutionTaskCancellationSource.Token);
},
......
......@@ -38,7 +38,6 @@ public async Task GetSymbolsAsync(GoToSymbolContext context)
// This means we have to query for "third party navigation", from
// XAML, etc. That call has to be done on the UI thread.
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
var solution = document.Project.Solution;
var definitions = GoToDefinitionHelpers.GetDefinitions(symbol, solution, thirdPartyNavigationAllowed: true, cancellationToken)
......
......@@ -637,7 +637,6 @@ private async Task<IEnumerable<Diagnostic>> GetProjectDiagnosticsAsync(Project p
// Have to see if this fix is still applicable. Jump to the foreground thread
// to make that check.
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
var applicable = fix.Action.IsApplicable(document.Project.Solution.Workspace);
......
......@@ -151,7 +151,6 @@ public virtual void Stop()
async tasks =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _stopCancellationToken);
_stopCancellationToken.ThrowIfCancellationRequested();
if (tasks.All(t => t.Status == TaskStatus.RanToCompletion))
{
......
......@@ -146,7 +146,6 @@ private void StartSelectedItemUpdateTask(int delay, bool updateUIWhenDone)
async t =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
PushSelectedItemsToPresenter(t.Result);
},
......
......@@ -79,7 +79,6 @@ public TrackingSession(StateMachine stateMachine, SnapshotSpan snapshotSpan, IAs
async t =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _cancellationToken);
_cancellationToken.ThrowIfCancellationRequested();
stateMachine.UpdateTrackingSessionIfRenamable();
},
......@@ -107,7 +106,6 @@ private void QueueUpdateToStateMachine(StateMachine stateMachine, Task task)
task.SafeContinueWithFromAsync(async t =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _cancellationToken);
_cancellationToken.ThrowIfCancellationRequested();
if (_isRenamableIdentifierTask.Result != TriggerIdentifierKind.NotRenamable)
{
......
......@@ -85,7 +85,6 @@ public Task InvokeBelowInputPriorityAsync(Action action, CancellationToken cance
async () =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
action();
},
......
......@@ -124,7 +124,6 @@ public void Cancel()
async t =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
if (t.Result != null)
{
......
......@@ -78,7 +78,6 @@ private async Task<bool> FixHierarchyContentAsync(IVsHierarchyCodeCleanupScope h
var hierarchyToProjectMap = _workspace.Services.GetRequiredService<IHierarchyItemToProjectIdMap>();
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(context.OperationContext.UserCancellationToken);
context.OperationContext.UserCancellationToken.ThrowIfCancellationRequested();
ProjectId projectId = null;
if (ErrorHandler.Succeeded(hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID8.VSHPROPID_ActiveIntellisenseProjectContext, out var contextProjectNameObject))
......@@ -224,7 +223,6 @@ async Task<Solution> ApplyFixAsync(ProgressTracker progressTracker, Cancellation
var solution = await applyFixAsync(progressTracker, cancellationToken).ConfigureAwait(true);
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
return workspace.TryApplyChanges(solution, progressTracker);
}
......
......@@ -188,7 +188,6 @@ private void AddFilteredInfos(ImmutableArray<DesignerAttributeData> data, ArrayB
{
// legacy project system can only be talked to on the UI thread.
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
AssertIsForeground();
......@@ -287,7 +286,6 @@ private void AddFilteredInfos(ImmutableArray<DesignerAttributeData> data, ArrayB
if (!_cpsProjects.TryGetValue(projectId, out var updateService))
{
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
this.AssertIsForeground();
updateService = ComputeUpdateService();
......
......@@ -313,7 +313,6 @@ async Task<OLECMDF> QueryStatusAsync(uint cmdId)
cmds[0].cmdf = 0;
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
var hr = _oleCommandTarget.QueryStatus(ReSharperCommandGroup, (uint)cmds.Length, cmds, IntPtr.Zero);
if (ErrorHandler.Failed(hr))
......@@ -335,7 +334,6 @@ async Task EnsureOleCommandTargetAsync()
}
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
_oleCommandTarget = _serviceProvider.GetService<IOleCommandTarget, SUIHostCommandDispatcher>();
}
......
......@@ -398,7 +398,6 @@ private void OnWorkspaceChanged(bool localSolutionChanged, ProjectId localChange
async _ =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
ProcessBatchedChangesOnForeground(cancellationToken);
},
......@@ -443,7 +442,6 @@ private void ProcessBatchedChangesOnForeground(CancellationToken cancellationTok
async () =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
ProcessBatchedChangesOnForeground(cancellationToken);
},
......
......@@ -20,7 +20,6 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
{
await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(true);
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
var shell = (IVsShell)await GetServiceAsync(typeof(SVsShell));
ErrorHandler.ThrowOnFailure(shell.IsPackageInstalled(s_compilerPackage, out var installed));
......
......@@ -53,7 +53,6 @@ protected static void InvokeOnUIThread(Action<CancellationToken> action)
var operation = JoinableTaskFactory.RunAsync(async () =>
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationTokenSource.Token);
cancellationTokenSource.Token.ThrowIfCancellationRequested();
action(cancellationTokenSource.Token);
});
......@@ -67,7 +66,6 @@ protected static T InvokeOnUIThread<T>(Func<CancellationToken, T> action)
var operation = JoinableTaskFactory.RunAsync(async () =>
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationTokenSource.Token);
cancellationTokenSource.Token.ThrowIfCancellationRequested();
return action(cancellationTokenSource.Token);
});
......
......@@ -102,7 +102,6 @@ public async Task EnsureProjectsLoadedAsync(CancellationToken cancellationToken)
private async Task LoadRoslynPackageAsync(CancellationToken cancellationToken)
{
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
// Explicitly trigger the load of the Roslyn package. This ensures that UI-bound services are appropriately prefetched,
// that FatalError is correctly wired up, etc. Ideally once the things happening in the package initialize are cleaned up with
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册