DbExecutionStrategy.ExecuteAsync Method

 

Namespace:   System.Data.Entity.Infrastructure
Assembly:  EntityFramework (in EntityFramework.dll)

NameDescription
System_CAPS_pubmethodExecuteAsync(Func<Task>, CancellationToken)

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

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

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


DbExecutionStrategy.ExecuteAsync Method (Func<Task>, CancellationToken)

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

public Task ExecuteAsync(
	Func<Task> operation,
	CancellationToken cancellationToken
)

Parameters

operation
Type: System.Func<Task>

A function that returns a started task.

cancellationToken
Type: System.Threading.CancellationToken

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

Return Value

Type: System.Threading.Tasks.Task

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.

Exception Condition
RetryLimitExceededException

If the retry delay strategy determines the operation should not be retried anymore.

InvalidOperationException

If an existing transaction is detected and the execution strategy does not support it.

InvalidOperationException

If this instance was already used to execute an operation.


DbExecutionStrategy.ExecuteAsync<TResult> Method (Func<Task<TResult>>, CancellationToken)

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

[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public Task<TResult> ExecuteAsync<TResult>(
	Func<Task<TResult>> operation,
	CancellationToken cancellationToken
)

Parameters

operation
Type: System.Func<Task<TResult>>

A function that returns a started task of type TResult.

cancellationToken
Type: System.Threading.CancellationToken

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

Return Value

Type: System.Threading.Tasks.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.

Type Parameters

TResult

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

Exception Condition
RetryLimitExceededException

If the retry delay strategy determines the operation should not be retried anymore.

InvalidOperationException

If an existing transaction is detected and the execution strategy does not support it.

InvalidOperationException

If this instance was already used to execute an operation.