Share via


SqlRetryLogicBaseProvider.ExecuteAsync Method

Definition

Overloads

ExecuteAsync(Object, Func<Task>, CancellationToken)

Executes a function and applies retry logic, if enabled. The cancellation token can be used to request that the operation be abandoned before the execution attempts are exceeded. Note: Exceptions will be reported via the returned Task object, which will contain an aggregate exception if execution fails for all retry attempts.

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

Executes a function and applies retry logic, if enabled. The cancellation token can be used to request that the operation be abandoned before the execution attempts are exceeded. Note: Exceptions will be reported via the returned Task object, which will contain an aggregate exception if execution fails for all retry attempts.

ExecuteAsync(Object, Func<Task>, CancellationToken)

Executes a function and applies retry logic, if enabled. The cancellation token can be used to request that the operation be abandoned before the execution attempts are exceeded. Note: Exceptions will be reported via the returned Task object, which will contain an aggregate exception if execution fails for all retry attempts.

public abstract System.Threading.Tasks.Task ExecuteAsync (object sender, Func<System.Threading.Tasks.Task> function, System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteAsync : obj * Func<System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public MustOverride Function ExecuteAsync (sender As Object, function As Func(Of Task), Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

sender
Object

The source of the event.

function
Func<Task>

The operation to re-execute if a transient condition occurs.

cancellationToken
CancellationToken

The cancellation instruction.

Returns

A Task or an exception.

Exceptions

The function parameter can't be null.

The collection of exceptions after failed retry attempts.

Remarks

Note

If the exception comes from all retry attempts failing, it will be an AggregateException that consists of all exceptions from the failed attempts.

Applies to

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

Executes a function and applies retry logic, if enabled. The cancellation token can be used to request that the operation be abandoned before the execution attempts are exceeded. Note: Exceptions will be reported via the returned Task object, which will contain an aggregate exception if execution fails for all retry attempts.

public abstract System.Threading.Tasks.Task<TResult> ExecuteAsync<TResult> (object sender, Func<System.Threading.Tasks.Task<TResult>> function, System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteAsync : obj * Func<System.Threading.Tasks.Task<'Result>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
Public MustOverride Function ExecuteAsync(Of TResult) (sender As Object, function As Func(Of Task(Of TResult)), Optional cancellationToken As CancellationToken = Nothing) As Task(Of TResult)

Type Parameters

TResult

The object that the function returns in a Task when executed.

Parameters

sender
Object

The source of the event.

function
Func<Task<TResult>>

The operation to re-execute if a transient condition occurs.

cancellationToken
CancellationToken

The cancellation instruction.

Returns

Task<TResult>

A task representing the asynchronous operation. The results of the task will be the return value of the function, if it runs without exception.

Exceptions

The function parameter can't be null.

The collection of exceptions after failed retry attempts.

Remarks

Note

If the exception comes from all retry attempts failing, it will be an AggregateException that consists of all exceptions from the failed attempts.

Applies to