提交 529e0e00 编写于 作者: H Heejae Chang 提交者: GitHub

Merge pull request #16264 from heejaechang/fixCancellationHandling

Fix cancellation handling
......@@ -48,6 +48,7 @@ protected override async Task ExecuteAsync()
{
// we wait for global operation, higher and normal priority processor to finish its working
await WaitForHigherPriorityOperationsAsync().ConfigureAwait(false);
// process any available project work, preferring the active project.
if (_workItemQueue.TryTakeAnyWork(
this.Processor.GetActiveProject(), this.Processor.DependencyGraph, this.Processor.DiagnosticAnalyzerService,
......@@ -149,9 +150,12 @@ private async Task ProcessProjectAsync(ImmutableArray<IIncrementalAnalyzer> anal
RemoveProject(projectId);
}
}
processedEverything = true;
if (!cancellationToken.IsCancellationRequested)
{
processedEverything = true;
}
}
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
{
......
......@@ -330,6 +330,7 @@ private async Task ProcessDocumentAsync(ImmutableArray<IIncrementalAnalyzer> ana
{
var cancellationToken = source.Token;
var document = _processingSolution.GetDocument(documentId);
if (document != null)
{
await TrackSemanticVersionsAsync(document, workItem, cancellationToken).ConfigureAwait(false);
......
......@@ -183,10 +183,16 @@ private static bool ReportUnlessCanceled(Exception ex, CancellationToken token)
private static void RaiseCancellationIfInvokeFailed(Task task, CancellationTokenSource mergedCancellation, CancellationToken cancellationToken)
{
// if invoke throws an exception, make sure we raise cancellation
var dummy = task.ContinueWith(_ =>
var dummy = task.ContinueWith(p =>
{
try
{
if (p.Exception != null && !cancellationToken.IsCancellationRequested)
{
// fail fast if we are here without cencellation raised.
FatalError.Report(p.Exception);
}
mergedCancellation.Cancel();
}
catch (ObjectDisposedException)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册