Share via


NonRetryingExecutionStrategy.ExecuteAsync<TState,TResult> Method

Definition

Executes the specified asynchronous operation and returns the result.

public System.Threading.Tasks.Task<TResult> ExecuteAsync<TState,TResult> (TState state, Func<Microsoft.EntityFrameworkCore.DbContext,TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, Func<Microsoft.EntityFrameworkCore.DbContext,TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>>> verifySucceeded, System.Threading.CancellationToken cancellationToken = default);
public System.Threading.Tasks.Task<TResult> ExecuteAsync<TState,TResult> (TState state, Func<Microsoft.EntityFrameworkCore.DbContext,TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, Func<Microsoft.EntityFrameworkCore.DbContext,TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.ExecutionResult<TResult>>>? verifySucceeded, System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteAsync : 'State * Func<Microsoft.EntityFrameworkCore.DbContext, 'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * Func<Microsoft.EntityFrameworkCore.DbContext, 'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.ExecutionResult<'Result>>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
override this.ExecuteAsync : 'State * Func<Microsoft.EntityFrameworkCore.DbContext, 'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * Func<Microsoft.EntityFrameworkCore.DbContext, 'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.ExecutionResult<'Result>>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
Public Function ExecuteAsync(Of TState, TResult) (state As TState, operation As Func(Of DbContext, TState, CancellationToken, Task(Of TResult)), verifySucceeded As Func(Of DbContext, TState, CancellationToken, Task(Of ExecutionResult(Of TResult))), 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

state
TState

The state that will be passed to the operation.

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

A function that returns a started task of type TResult.

verifySucceeded
Func<DbContext,TState,CancellationToken,Task<ExecutionResult<TResult>>>

A delegate that tests whether the operation succeeded even though an exception was thrown.

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.

Implements

Exceptions

The operation has not succeeded after the configured number of retries.

Remarks

See Connection resiliency and database retries for more information and examples.

Applies to