File tree 1 file changed +13
-2
lines changed
src/Microsoft.TemplateEngine.Edge/Constraints
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ namespace Microsoft.TemplateEngine.Edge.Constraints
11
11
{
12
12
public sealed class WorkloadConstraintFactory : ITemplateConstraintFactory
13
13
{
14
+ private static readonly SemaphoreSlim Mutex = new ( 1 ) ;
15
+
14
16
Guid IIdentifiedComponent . Id { get ; } = Guid . Parse ( "{F8BA5B13-7BD6-47C8-838C-66626526817B}" ) ;
15
17
16
18
string ITemplateConstraintFactory . Type => "workload" ;
@@ -97,8 +99,17 @@ private static IEnumerable<string> ParseArgs(string? args)
97
99
}
98
100
99
101
token . ThrowIfCancellationRequested ( ) ;
100
- IEnumerable < WorkloadInfo > currentProviderWorkloads = await providers [ 0 ] . GetInstalledWorkloadsAsync ( token ) . ConfigureAwait ( false ) ;
101
- workloads = currentProviderWorkloads . ToList ( ) ;
102
+
103
+ await Mutex . WaitAsync ( token ) . ConfigureAwait ( false ) ;
104
+ try
105
+ {
106
+ IEnumerable < WorkloadInfo > currentProviderWorkloads = await providers [ 0 ] . GetInstalledWorkloadsAsync ( token ) . ConfigureAwait ( false ) ;
107
+ workloads = currentProviderWorkloads . ToList ( ) ;
108
+ }
109
+ finally
110
+ {
111
+ Mutex . Release ( ) ;
112
+ }
102
113
103
114
if ( workloads . Select ( w => w . Id ) . HasDuplicates ( StringComparer . InvariantCultureIgnoreCase ) )
104
115
{
You can’t perform that action at this time.
0 commit comments