diff --git a/src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs b/src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
index 63632ccb26df0a7bf35229e0a7eb009dba899129..3a91041bd574dab9b5c2f659a0ede0619bfb02a9 100644
--- a/src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
+++ b/src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
@@ -10,12 +10,17 @@ namespace Microsoft.CodeAnalysis.SolutionCrawler
internal interface ISolutionCrawlerProgressReporter
{
///
- /// Raised when there is pending work in solution crawler
+ /// Return true if solution crawler is in progress.
+ ///
+ bool InProgress { get; }
+
+ ///
+ /// Raised when there is pending work in solution crawler.
///
event EventHandler Started;
///
- /// Raised when there is no more pending work in solutino crawler
+ /// Raised when there is no more pending work in solutino crawler.
///
event EventHandler Stopped;
}
diff --git a/src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs b/src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
index 2c9f3f9d8c8a2c5b5a9541c6fb57469736d9ac19..f3e3f48777edc19cb4fba50692bf2765abaffe8b 100644
--- a/src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
+++ b/src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
@@ -25,6 +25,14 @@ private class SolutionCrawlerProgressReporter : ISolutionCrawlerProgressReporter
private int _count = 0;
+ public bool InProgress
+ {
+ get
+ {
+ return _count > 0;
+ }
+ }
+
public event EventHandler Started
{
add
@@ -103,6 +111,14 @@ private class NullReporter : ISolutionCrawlerProgressReporter
{
public static readonly NullReporter Instance = new NullReporter();
+ public bool InProgress
+ {
+ get
+ {
+ return false;
+ }
+ }
+
public event EventHandler Started
{
add { }
diff --git a/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs b/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs
index f25e642830ebf9eea1ad37a0edbb1f5ae1d003bd..4c9394635de530484d94d8788e85284d087fb07b 100644
--- a/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs
+++ b/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs
@@ -14,6 +14,11 @@ private class AsyncDocumentWorkItemQueue : AsyncWorkItemQueue
{
private readonly Dictionary> _documentWorkQueue = new Dictionary>();
+ public AsyncDocumentWorkItemQueue(SolutionCrawlerProgressReporter progressReporter) :
+ base(progressReporter)
+ {
+ }
+
protected override int WorkItemCount_NoLock
{
get
diff --git a/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs b/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs
index 08397013d023f7e2cde859993516812ad9b35024..c1cb9cd66c24267ca1faffcfb39dae39b7cb349a 100644
--- a/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs
+++ b/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs
@@ -15,6 +15,11 @@ private sealed class AsyncProjectWorkItemQueue : AsyncWorkItemQueue
{
private readonly Dictionary _projectWorkQueue = new Dictionary();
+ public AsyncProjectWorkItemQueue(SolutionCrawlerProgressReporter progressReporter) :
+ base(progressReporter)
+ {
+ }
+
protected override int WorkItemCount_NoLock
{
get
diff --git a/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs b/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs
index 3a3efb6016e24c07558c059ef65acaae2ebbf5fa..20f1a358dd7f6560dad0e198c75f95482eacfc59 100644
--- a/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs
+++ b/src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs
@@ -15,12 +15,20 @@ private partial class WorkCoordinator
private abstract class AsyncWorkItemQueue : IDisposable
where TKey : class
{
- private readonly AsyncSemaphore _semaphore = new AsyncSemaphore(initialCount: 0);
+ private readonly object _gate;
+ private readonly AsyncSemaphore _semaphore;
+ private readonly SolutionCrawlerProgressReporter _progressReporter;
// map containing cancellation source for the item given out.
- private readonly Dictionary