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 27ad7dbbcf3..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,11 +948,8 @@ 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) { - await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - IReadOnlyCollection packageSources = SelectedSource.PackageSources; - // Switch off the UI thread before fetching installed packages and deprecation metadata. await TaskScheduler.Default;