Share via


DbExecutionStrategy Class

Definition

Provides the base implementation of the retry mechanism for unreliable operations and transient conditions that uses exponentially increasing delays between retries.

public abstract class DbExecutionStrategy : System.Data.Entity.Infrastructure.IDbExecutionStrategy
type DbExecutionStrategy = class
    interface IDbExecutionStrategy
Public MustInherit Class DbExecutionStrategy
Implements IDbExecutionStrategy
Inheritance
DbExecutionStrategy
Derived
Implements

Remarks

A new instance will be created each time an operation is executed. The following formula is used to calculate the delay after retryCount number of attempts: min(random(1, 1.1) * (2 ^ retryCount - 1), maxDelay) The retryCount starts at 0. The random factor distributes uniformly the retry attempts from multiple simultaneous operations failing simultaneously.

Constructors

DbExecutionStrategy()

Creates a new instance of DbExecutionStrategy.

DbExecutionStrategy(Int32, TimeSpan)

Creates a new instance of DbExecutionStrategy with the specified limits for number of retries and the delay between retries.

Properties

RetriesOnFailure

Returns true to indicate that DbExecutionStrategy might retry the execution after a failure.

Suspended

Indicates whether the strategy is suspended. The strategy is typically suspending while executing to avoid recursive execution from nested operations.

Methods

Execute(Action)

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

Execute<TResult>(Func<TResult>)

Repetitively executes the specified 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.

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

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

GetNextDelay(Exception)

Determines whether the operation should be retried and the delay before the next attempt.

ShouldRetryOn(Exception)

Determines whether the specified exception represents a transient failure that can be compensated by a retry.

UnwrapAndHandleException<T>(Exception, Func<Exception,T>)

Recursively gets InnerException from exception as long as it's an EntityException, DbUpdateException or UpdateException and passes it to exceptionHandler

Applies to