Skip to content

Commit

Permalink
Merge pull request #8734 from dotnet/merge/release/9.0.2xx-to-release…
Browse files Browse the repository at this point in the history
…/9.0.3xx

[automated] Merge branch 'release/9.0.2xx' => 'release/9.0.3xx'
  • Loading branch information
v-wuzhai authored Feb 6, 2025
2 parents a8fd123 + d0e0b2c commit be07bbf
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Microsoft.TemplateEngine.Edge.Constraints
{
public sealed class WorkloadConstraintFactory : ITemplateConstraintFactory
{
private static readonly SemaphoreSlim Mutex = new(1);

Guid IIdentifiedComponent.Id { get; } = Guid.Parse("{F8BA5B13-7BD6-47C8-838C-66626526817B}");

string ITemplateConstraintFactory.Type => "workload";
Expand Down Expand Up @@ -97,8 +99,17 @@ private static IEnumerable<string> ParseArgs(string? args)
}

token.ThrowIfCancellationRequested();
IEnumerable<WorkloadInfo> currentProviderWorkloads = await providers[0].GetInstalledWorkloadsAsync(token).ConfigureAwait(false);
workloads = currentProviderWorkloads.ToList();

await Mutex.WaitAsync(token).ConfigureAwait(false);
try
{
IEnumerable<WorkloadInfo> currentProviderWorkloads = await providers[0].GetInstalledWorkloadsAsync(token).ConfigureAwait(false);
workloads = currentProviderWorkloads.ToList();
}
finally
{
Mutex.Release();
}

if (workloads.Select(w => w.Id).HasDuplicates(StringComparer.InvariantCultureIgnoreCase))
{
Expand Down

0 comments on commit be07bbf

Please sign in to comment.