Delen via


ExecutionStrategy.ExecuteInTransactionAsync<TState,TResult> Method

Definition

Executes the specified asynchronous operation and returns the result.

public virtual System.Threading.Tasks.Task<TResult> ExecuteInTransactionAsync<TState,TResult> (Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<bool>> verifySucceeded, TState state, System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteInTransactionAsync : Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<bool>> * 'State * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
override this.ExecuteInTransactionAsync : Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<bool>> * 'State * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
Public Overridable Function ExecuteInTransactionAsync(Of TState, TResult) (operation As Func(Of TState, CancellationToken, Task(Of TResult)), verifySucceeded As Func(Of TState, CancellationToken, Task(Of Boolean)), state As TState, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TResult)

Type Parameters

TState

The type of the state.

TResult

The result type of the Task<TResult> returned by operation.

Parameters

operation
Func<TState,CancellationToken,Task<TResult>>

A function that returns a started task of type TResult.

verifySucceeded
Func<TState,CancellationToken,Task<Boolean>>

A delegate that tests whether the operation succeeded even though an exception was thrown when the transaction was being committed.

state
TState

The state that will be passed to the operation.

cancellationToken
CancellationToken

A cancellation token used to cancel the retry operation, but not operations that are already in flight or that already completed successfully.

Returns

Task<TResult>

A task that will run to completion if the original task completes successfully (either the first time or after retrying transient failures). If the task fails with a non-transient error or the retry limit is reached, the returned task will become faulted and the exception must be observed.

Exceptions

Thrown if the operation has not succeeded after the configured number of retries.

Applies to