API Reference
Class
DynamicSemaphoreManager
Provides a semaphore whose concurrency level is determined dynamically based on the environment.
Inheritance
- Object
- DynamicSemaphoreManager
Constructors
public DynamicSemaphoreManager(Nullable<Int32> maxConcurrency = null) #Creates a new instance with optional override for maximum concurrency.
Parameters
- maxConcurrency System.Nullable{System.Int32} = null
- Maximum number of concurrent operations. If null, Environment.ProcessorCount is used.
Methods
public async Task<TResult> RunAsync<TResult>(Func<Task<TResult>> action, CancellationToken cancellationToken = null) #Returns:
Task<TResult>Type Parameters
- TResult
Parameters
- action Func<Task<TResult>>
- cancellationToken CancellationToken = null
RunAsync``1(System.Func{System.Threading.Tasks.Task{``0}} action, System.Threading.CancellationToken cancellationToken) #Runs the provided asynchronous delegate while enforcing the semaphore limit.
Parameters
- action System.Func{System.Threading.Tasks.Task{``0}}
- Asynchronous action to execute.
- cancellationToken System.Threading.CancellationToken
- Cancellation token.