Share via


DbExecutionStrategy.ExecuteAsync Method

Definition

Overloads

ExecuteAsync(Func<Task>, CancellationToken)

Repetitively executes the specified asynchronous operation while it satisfies the current retry policy.

ExecuteAsync<TResult>(Func<Task<TResult>>, CancellationToken)

Repeatedly executes the specified asynchronous operation while it satisfies the current retry policy.

ExecuteAsync(Func<Task>, CancellationToken)

Repetitively executes the specified asynchronous operation while it satisfies the current retry policy.

public System.Threading.Tasks.Task ExecuteAsync (Func<System.Threading.Tasks.Task> operation, System.Threading.CancellationToken cancellationToken);
abstract member ExecuteAsync : Func<System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.ExecuteAsync : Func<System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task

Parameters

operation
Func<Task>

A function that returns a started task.

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

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

if the retry delay strategy determines the operation shouldn't be retried anymore

if this instance was already used to execute an operation

Applies to

ExecuteAsync<TResult>(Func<Task<TResult>>, CancellationToken)

Repeatedly executes the specified asynchronous operation while it satisfies the current retry policy.

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public System.Threading.Tasks.Task<TResult> ExecuteAsync<TResult> (Func<System.Threading.Tasks.Task<TResult>> operation, System.Threading.CancellationToken cancellationToken);
abstract member ExecuteAsync : Func<System.Threading.Tasks.Task<'Result>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
override this.ExecuteAsync : Func<System.Threading.Tasks.Task<'Result>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>

Type Parameters

TResult

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

Parameters

operation
Func<Task<TResult>>

A function that returns a started task of type TResult.

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

Attributes

Exceptions

if the retry delay strategy determines the operation shouldn't be retried anymore

if this instance was already used to execute an operation

Applies to