TestimoX

API Reference

Class

DynamicSemaphoreManager

Namespace TestimoX.Infrastructure
Assembly TestimoX

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 optionalposition: 0
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>> requiredposition: 0
cancellationToken CancellationToken = null optionalposition: 1
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}} required
Asynchronous action to execute.
cancellationToken System.Threading.CancellationToken required
Cancellation token.