提交 983e1b2f 编写于 作者: H Heejae Chang

Merge pull request #777 from heejaechang/solutionCancel

make solution crawler to cancel all running tasks on global operation
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.Internal.Log;
using Roslyn.Utilities;
......
......@@ -99,6 +99,15 @@ public bool AddOrReplace(WorkItem item)
}
}
public void RequestCancellationOnRunningTasks()
{
lock (_gate)
{
// request to cancel all running works
_cancellationMap.Do(p => p.Value.Cancel());
}
}
public void Dispose()
{
lock (_gate)
......
......@@ -45,6 +45,8 @@ private abstract class GlobalOperationAwareIdleProcessor : IdleProcessor
_globalOperationNotificationService.Stopped += OnGlobalOperationStopped;
}
protected abstract void PauseOnGlobalOperation();
private void OnGlobalOperationStarted(object sender, EventArgs e)
{
Contract.ThrowIfFalse(_globalOperation == null);
......@@ -54,6 +56,8 @@ private void OnGlobalOperationStarted(object sender, EventArgs e)
_globalOperationTask = _globalOperation.Task;
SolutionCrawlerLogger.LogGlobalOperation(this.Processor._logAggregator);
PauseOnGlobalOperation();
}
private void OnGlobalOperationStopped(object sender, GlobalOperationEventArgs e)
......
......@@ -75,6 +75,11 @@ protected override async Task ExecuteAsync()
}
}
protected override void PauseOnGlobalOperation()
{
_workItemQueue.RequestCancellationOnRunningTasks();
}
public void Enqueue(WorkItem item)
{
this.UpdateLastAccessTime();
......
......@@ -183,6 +183,11 @@ protected override async Task ExecuteAsync()
}
}
protected override void PauseOnGlobalOperation()
{
_workItemQueue.RequestCancellationOnRunningTasks();
}
private void SetProjectProcessing(ProjectId currentProject)
{
if (currentProject != _currentProjectProcessing)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册