Example #1
0
        private async Task ProgressItemsCompletedAsync(int count, CancellationToken cancellationToken)
        {
            var newValue = Interlocked.Add(ref _remainingProgressItems, -count);

            Debug.Assert(newValue >= 0);
            await _progress_doNotAccessDirectly.ItemsCompletedAsync(count, cancellationToken).ConfigureAwait(false);
        }
Example #2
0
        private async Task SearchAllProjectsAsync(bool isFullyLoaded, CancellationToken cancellationToken)
        {
            var seenItems                = new HashSet <INavigateToSearchResult>(NavigateToSearchResultComparer.Instance);
            var orderedProjects          = GetOrderedProjectsToProcess();
            var searchGeneratedDocuments = isFullyLoaded;

            var projectCount = orderedProjects.Sum(g => g.Length);

            // We do at least two passes.  One for loaded docs.  One for source generated docs.
            await _progress.AddItemsAsync(projectCount * 2, cancellationToken).ConfigureAwait(false);

            if (!isFullyLoaded)
            {
                // We need an additional pass to look through cached docs.
                await _progress.AddItemsAsync(projectCount, cancellationToken).ConfigureAwait(false);

                await SearchCachedDocumentsAsync(orderedProjects, seenItems, cancellationToken).ConfigureAwait(false);

                // If searching cached data returned any results, then we're done.  We've at least shown some results
                // to the user.  That will hopefully serve them well enough until the solution fully loads.
                if (seenItems.Count > 0)
                {
                    // Ensure that we actually complete all our workitems so that the progress bar completes.
                    await _progress.ItemsCompletedAsync(projectCount * 2, cancellationToken).ConfigureAwait(false);

                    return;
                }
            }

            await SearchFullyLoadedProjectsAsync(orderedProjects, seenItems, cancellationToken).ConfigureAwait(false);
            await SearchGeneratedDocumentsAsync(seenItems, cancellationToken).ConfigureAwait(false);

            // Report a telemetry even to track if we found uncached items after failing to find cached items.
            // In practice if we see that we are always finding uncached items, then it's likely something
            // has broken in the caching system since we would expect to normally find values there.  Specifically
            // we expect: foundFullItems <<< not foundFullItems.
            if (!isFullyLoaded)
            {
                Logger.Log(FunctionId.NavigateTo_CacheItemsMiss, KeyValueLogMessage.Create(m => m["FoundFullItems"] = seenItems.Count > 0));
            }
        }
 public static ValueTask ItemCompletedAsync(this IStreamingProgressTracker tracker, CancellationToken cancellationToken)
 => tracker.ItemsCompletedAsync(1, cancellationToken);