ExecutionStrategyExtensions.ExecuteAsync Method

Definition

Overloads

ExecuteAsync(IExecutionStrategy, Func<Task>)

Executes the specified asynchronous operation.

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

Executes the specified asynchronous operation.

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

Executes the specified asynchronous operation and returns the result.

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

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState, CancellationToken,Task<TResult>>, Func<TState,CancellationToken, Task<ExecutionResult<TResult>>>, CancellationToken)

Executes the specified asynchronous operation and returns the result.

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

Executes the specified asynchronous operation and returns the result.

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

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState,Task<TResult>>)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState,TResult>(IExecutionStrategy, Func<TState,Task<TResult>>, TState)

Executes the specified asynchronous operation and returns the result.

ExecuteAsync<TState>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task>, CancellationToken)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, Func<TState,CancellationToken,Task>, TState, CancellationToken)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, TState, Func<TState,Task>)

Executes the specified asynchronous operation.

ExecuteAsync<TState>(IExecutionStrategy, Func<TState,Task>, TState)

Executes the specified asynchronous operation.

ExecuteAsync(IExecutionStrategy, Func<Task>)

Executes the specified asynchronous operation.

public static System.Threading.Tasks.Task ExecuteAsync (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.Tasks.Task> operation);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.Tasks.Task> -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteAsync (strategy As IExecutionStrategy, operation As Func(Of Task)) As Task

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<Task>

A function that returns a started task.

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.

Remarks

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

Applies to

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

Executes the specified asynchronous operation.

public static System.Threading.Tasks.Task ExecuteAsync (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task> operation, System.Threading.CancellationToken cancellationToken);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteAsync (strategy As IExecutionStrategy, operation As Func(Of CancellationToken, Task), cancellationToken As CancellationToken) As Task

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<CancellationToken,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.

Exceptions

Remarks

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

Applies to

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

Executes the specified asynchronous operation and returns the result.

public static System.Threading.Tasks.Task<TResult> ExecuteAsync<TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.Tasks.Task<TResult>> operation);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.Tasks.Task<'Result>> -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteAsync(Of TResult) (strategy As IExecutionStrategy, operation As Func(Of Task(Of TResult))) As Task(Of TResult)

Type Parameters

TResult

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

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<Task<TResult>>

A function that returns a started task of type TResult.

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.

Remarks

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

Applies to

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

Executes the specified asynchronous operation and returns the result.

public static System.Threading.Tasks.Task<TResult> ExecuteAsync<TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, System.Threading.CancellationToken cancellationToken);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteAsync(Of TResult) (strategy As IExecutionStrategy, operation As Func(Of CancellationToken, Task(Of TResult)), cancellationToken As CancellationToken) As Task(Of TResult)

Type Parameters

TResult

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

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<CancellationToken,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.

Exceptions

Remarks

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

Applies to

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState, CancellationToken,Task<TResult>>, Func<TState,CancellationToken, Task<ExecutionResult<TResult>>>, CancellationToken)

Executes the specified asynchronous operation and returns the result.

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

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

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

A function that returns a started task of type TResult.

verifySucceeded
Func<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.

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

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

Executes the specified asynchronous operation and returns the result.

public static System.Threading.Tasks.Task<TResult> ExecuteAsync<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, System.Threading.CancellationToken cancellationToken);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteAsync(Of TState, TResult) (strategy As IExecutionStrategy, state As TState, operation As Func(Of TState, CancellationToken, Task(Of TResult)), cancellationToken As CancellationToken) As Task(Of TResult)

Type Parameters

TState

The type of the state.

TResult

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

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Func<TState,CancellationToken,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.

Exceptions

Remarks

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

Applies to

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

Executes the specified asynchronous operation and returns the result.

public static System.Threading.Tasks.Task<TResult> ExecuteAsync<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task<TResult>> operation, TState state, System.Threading.CancellationToken cancellationToken);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Result>> * 'State * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteAsync(Of TState, TResult) (strategy As IExecutionStrategy, operation As Func(Of TState, CancellationToken, Task(Of TResult)), state As TState, cancellationToken As CancellationToken) As Task(Of TResult)

Type Parameters

TState

The type of the state.

TResult

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

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

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

A function that returns a started task of type TResult.

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.

Applies to

ExecuteAsync<TState,TResult>(IExecutionStrategy, TState, Func<TState,Task<TResult>>)

Executes the specified asynchronous operation and returns the result.

public static System.Threading.Tasks.Task<TResult> ExecuteAsync<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,System.Threading.Tasks.Task<TResult>> operation);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * 'State * Func<'State, System.Threading.Tasks.Task<'Result>> -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteAsync(Of TState, TResult) (strategy As IExecutionStrategy, state As TState, operation As Func(Of TState, Task(Of TResult))) As Task(Of TResult)

Type Parameters

TState

The type of the state.

TResult

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

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Func<TState,Task<TResult>>

A function that returns a started task of type TResult.

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.

Remarks

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

Applies to

ExecuteAsync<TState,TResult>(IExecutionStrategy, Func<TState,Task<TResult>>, TState)

Executes the specified asynchronous operation and returns the result.

public static System.Threading.Tasks.Task<TResult> ExecuteAsync<TState,TResult> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,System.Threading.Tasks.Task<TResult>> operation, TState state);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<'State, System.Threading.Tasks.Task<'Result>> * 'State -> System.Threading.Tasks.Task<'Result>
<Extension()>
Public Function ExecuteAsync(Of TState, TResult) (strategy As IExecutionStrategy, operation As Func(Of TState, Task(Of TResult)), state As TState) As Task(Of TResult)

Type Parameters

TState

The type of the state.

TResult

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

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<TState,Task<TResult>>

A function that returns a started task of type TResult.

state
TState

The state that will be passed to the operation.

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.

Applies to

ExecuteAsync<TState>(IExecutionStrategy, TState, Func<TState,CancellationToken,Task>, CancellationToken)

Executes the specified asynchronous operation.

public static System.Threading.Tasks.Task ExecuteAsync<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task> operation, System.Threading.CancellationToken cancellationToken);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * 'State * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteAsync(Of TState) (strategy As IExecutionStrategy, state As TState, operation As Func(Of TState, CancellationToken, Task), cancellationToken As CancellationToken) As Task

Type Parameters

TState

The type of the state.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Func<TState,CancellationToken,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.

Exceptions

Remarks

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

Applies to

ExecuteAsync<TState>(IExecutionStrategy, Func<TState,CancellationToken,Task>, TState, CancellationToken)

Executes the specified asynchronous operation.

public static System.Threading.Tasks.Task ExecuteAsync<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,System.Threading.CancellationToken,System.Threading.Tasks.Task> operation, TState state, System.Threading.CancellationToken cancellationToken);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<'State, System.Threading.CancellationToken, System.Threading.Tasks.Task> * 'State * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteAsync(Of TState) (strategy As IExecutionStrategy, operation As Func(Of TState, CancellationToken, Task), state As TState, cancellationToken As CancellationToken) As Task

Type Parameters

TState

The type of the state.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<TState,CancellationToken,Task>

A function that returns a started task.

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

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.

Applies to

ExecuteAsync<TState>(IExecutionStrategy, TState, Func<TState,Task>)

Executes the specified asynchronous operation.

public static System.Threading.Tasks.Task ExecuteAsync<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, TState state, Func<TState,System.Threading.Tasks.Task> operation);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * 'State * Func<'State, System.Threading.Tasks.Task> -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteAsync(Of TState) (strategy As IExecutionStrategy, state As TState, operation As Func(Of TState, Task)) As Task

Type Parameters

TState

The type of the state.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

state
TState

The state that will be passed to the operation.

operation
Func<TState,Task>

A function that returns a started task.

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.

Remarks

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

Applies to

ExecuteAsync<TState>(IExecutionStrategy, Func<TState,Task>, TState)

Executes the specified asynchronous operation.

public static System.Threading.Tasks.Task ExecuteAsync<TState> (this Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy strategy, Func<TState,System.Threading.Tasks.Task> operation, TState state);
static member ExecuteAsync : Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy * Func<'State, System.Threading.Tasks.Task> * 'State -> System.Threading.Tasks.Task
<Extension()>
Public Function ExecuteAsync(Of TState) (strategy As IExecutionStrategy, operation As Func(Of TState, Task), state As TState) As Task

Type Parameters

TState

The type of the state.

Parameters

strategy
IExecutionStrategy

The strategy that will be used for the execution.

operation
Func<TState,Task>

A function that returns a started task.

state
TState

The state that will be passed to the operation.

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.

Applies to