ReentrantSemaphore.ExecuteAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ExecuteAsync(Func<Task>, CancellationToken) |
Executes a given operation within the semaphore. |
ExecuteAsync<T>(Func<ValueTask<T>>, CancellationToken) |
Executes a given operation within the semaphore. |
ExecuteAsync(Func<Task>, CancellationToken)
Executes a given operation within the semaphore.
public abstract System.Threading.Tasks.Task ExecuteAsync (Func<System.Threading.Tasks.Task> operation, System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteAsync : Func<System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public MustOverride Function ExecuteAsync (operation As Func(Of Task), Optional cancellationToken As CancellationToken = Nothing) As Task
Parameters
The delegate to invoke once the semaphore is entered. If a JoinableTaskContext was supplied to the constructor, this delegate will execute on the main thread if this is invoked on the main thread, otherwise it will be invoked on the threadpool. When no JoinableTaskContext is supplied to the constructor, this delegate will execute on the caller's context.
- cancellationToken
- CancellationToken
A cancellation token.
Returns
A task that completes with the result of operation
, after the semaphore has been exited.
Applies to
ExecuteAsync<T>(Func<ValueTask<T>>, CancellationToken)
Executes a given operation within the semaphore.
public abstract System.Threading.Tasks.ValueTask<T> ExecuteAsync<T> (Func<System.Threading.Tasks.ValueTask<T>> operation, System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteAsync : Func<System.Threading.Tasks.ValueTask<'T>> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'T>
Public MustOverride Function ExecuteAsync(Of T) (operation As Func(Of ValueTask(Of T)), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T)
Type Parameters
- T
The type of value returned by the operation.
Parameters
The delegate to invoke once the semaphore is entered. If a JoinableTaskContext was supplied to the constructor, this delegate will execute on the main thread if this is invoked on the main thread, otherwise it will be invoked on the threadpool. When no JoinableTaskContext is supplied to the constructor, this delegate will execute on the caller's context.
- cancellationToken
- CancellationToken
A cancellation token.
Returns
A task that completes with the result of operation
, after the semaphore has been exited.