diff --git a/src/NuGet.Clients/NuGet.PackageManagement.UI/Xamls/PackageManagerControl.xaml.cs b/src/NuGet.Clients/NuGet.PackageManagement.UI/Xamls/PackageManagerControl.xaml.cs index b03175d5e96..89712ac4134 100644 --- a/src/NuGet.Clients/NuGet.PackageManagement.UI/Xamls/PackageManagerControl.xaml.cs +++ b/src/NuGet.Clients/NuGet.PackageManagement.UI/Xamls/PackageManagerControl.xaml.cs @@ -934,7 +934,7 @@ private async ValueTask RefreshInstalledAndUpdatesTabsAsync() Interlocked.Exchange(ref _refreshCts, refreshCts)?.Cancel(); // Update installed tab warning icon - (int vulnerablePackages, int deprecatedPackages) = await GetInstalledVulnerableAndDeprecatedPackagesCountAsync(loadContext, refreshCts.Token); + (int vulnerablePackages, int deprecatedPackages) = await GetInstalledVulnerableAndDeprecatedPackagesCountAsync(loadContext, SelectedSource.PackageSources, refreshCts.Token); _topPanel.UpdateWarningStatusOnInstalledTab(vulnerablePackages, deprecatedPackages); // Update updates tab count @@ -948,7 +948,7 @@ private async ValueTask RefreshInstalledAndUpdatesTabsAsync() _topPanel.UpdateCountOnUpdatesTab(Model.CachedUpdates.Packages.Count); } - private async Task<(int, int)> GetInstalledVulnerableAndDeprecatedPackagesCountAsync(PackageLoadContext loadContext, CancellationToken token) + private async Task<(int, int)> GetInstalledVulnerableAndDeprecatedPackagesCountAsync(PackageLoadContext loadContext, IReadOnlyCollection packageSources, CancellationToken token) { // Switch off the UI thread before fetching installed packages and deprecation metadata. await TaskScheduler.Default; @@ -956,7 +956,7 @@ private async ValueTask RefreshInstalledAndUpdatesTabsAsync() PackageCollection installedPackages = await loadContext.GetInstalledPackagesAsync(); var installedPackageMetadata = await Task.WhenAll( - installedPackages.Select(p => GetPackageMetadataAsync(p, token))); + installedPackages.Select(p => GetPackageMetadataAsync(p, packageSources, token))); int vulnerablePackagesCount = 0; int deprecatedPackagesCount = 0; @@ -975,13 +975,12 @@ private async ValueTask RefreshInstalledAndUpdatesTabsAsync() return (vulnerablePackagesCount, deprecatedPackagesCount); } - private async Task<(PackageSearchMetadataContextInfo, PackageDeprecationMetadataContextInfo)> GetPackageMetadataAsync(PackageCollectionItem package, CancellationToken cancellationToken) + private async Task<(PackageSearchMetadataContextInfo, PackageDeprecationMetadataContextInfo)> GetPackageMetadataAsync(PackageCollectionItem package, IReadOnlyCollection packageSources, CancellationToken cancellationToken) { using (INuGetSearchService searchService = await _serviceBroker.GetProxyAsync(NuGetServices.SearchService, cancellationToken: cancellationToken)) { Assumes.NotNull(searchService); - await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - return await searchService.GetPackageMetadataAsync(package, SelectedSource.PackageSources, true, cancellationToken); + return await searchService.GetPackageMetadataAsync(package, packageSources, true, cancellationToken); } }