File tree 1 file changed +6
-4
lines changed
src/xunit.execution/Sdk/Frameworks/Runners
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -318,18 +318,20 @@ private void SetupParallelSemaphore(int maxParallelThreads)
318
318
var minThreads = ( int ) args [ 0 ] ;
319
319
var minIOPorts = ( int ) args [ 1 ] ;
320
320
321
- if ( minThreads < maxParallelThreads )
321
+ var threadFloor = Math . Min ( 4 , maxParallelThreads ) ;
322
+ if ( minThreads < threadFloor )
322
323
{
323
324
var setMethod = type . GetRuntimeMethod ( "SetMinThreads" , new [ ] { typeof ( int ) , typeof ( int ) } ) ;
324
325
if ( setMethod is null )
325
326
throw new InvalidOperationException ( "Cannot find method: System.Threading.ThreadPool.SetMinThreads" ) ;
326
327
327
- setMethod . Invoke ( null , new object [ ] { maxParallelThreads , minIOPorts } ) ;
328
+ setMethod . Invoke ( null , new object [ ] { threadFloor , minIOPorts } ) ;
328
329
}
329
330
#else
330
331
ThreadPool . GetMinThreads ( out var minThreads , out var minIOPorts ) ;
331
- if ( minThreads < maxParallelThreads )
332
- ThreadPool . SetMinThreads ( maxParallelThreads , minIOPorts ) ;
332
+ var threadFloor = Math . Min ( 4 , maxParallelThreads ) ;
333
+ if ( minThreads < threadFloor )
334
+ ThreadPool . SetMinThreads ( threadFloor , minIOPorts ) ;
333
335
#endif
334
336
}
335
337
You can’t perform that action at this time.
0 commit comments