Skip to content

Commit

Permalink
Use dotnet ForEachAsync implementation (#15936)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Alhayek <mike@crestapps.com>
  • Loading branch information
sebastienros and MikeAlhayek committed May 1, 2024
1 parent f0bc6d3 commit 2b8ebf7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.

This file was deleted.

6 changes: 2 additions & 4 deletions src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ private async Task EnsureInitializedAsync()
var loadedExtensions = new ConcurrentDictionary<string, ExtensionEntry>();

// Load all extensions in parallel
await modules.ForEachAsync((module) =>
Parallel.ForEach(modules, (module, cancellationToken) =>
{
if (!module.ModuleInfo.Exists)
{
return Task.CompletedTask;
return;
}
var manifestInfo = new ManifestInfo(module.ModuleInfo);
Expand All @@ -319,8 +319,6 @@ private async Task EnsureInitializedAsync()
};
loadedExtensions.TryAdd(module.Name, entry);
return Task.CompletedTask;
});

var loadedFeatures = new Dictionary<string, FeatureEntry>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)

private async Task RunAsync(IEnumerable<(string Tenant, long UtcTicks)> runningShells, CancellationToken stoppingToken)
{
await GetShellsToRun(runningShells).ForEachAsync(async tenant =>
await Parallel.ForEachAsync(GetShellsToRun(runningShells), async (tenant, cancellationToken) =>
{
// Check if the shell is still registered and running.
if (!_shellHost.TryGetShellContext(tenant, out var shell) || !shell.Settings.IsRunning())
Expand Down Expand Up @@ -238,7 +238,7 @@ private async Task RunAsync(IEnumerable<(string Tenant, long UtcTicks)> runningS
{
var referenceTime = DateTime.UtcNow;

await GetShellsToUpdate(previousShells, runningShells).ForEachAsync(async tenant =>
await Parallel.ForEachAsync(GetShellsToUpdate(previousShells, runningShells), async (tenant, cancellationToken) =>
{
if (stoppingToken.IsCancellationRequested)
{
Expand Down

0 comments on commit 2b8ebf7

Please sign in to comment.