<PackageReference Include="Polly" Version="8.5.0" />

AsyncFallbackTResultSyntax

public static class AsyncFallbackTResultSyntax
Fluent API for defining an async Fallback policy governing executions returning TResult.
public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, TResult fallbackValue)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, returns fallbackValue.

public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<CancellationToken, Task<TResult>> fallbackAction)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, asynchronously calls fallbackAction and returns its result.

public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, TResult fallbackValue, Func<DelegateResult<TResult>, Task> onFallbackAsync)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls onFallbackAsync with details of the handled exception or result; then returns fallbackValue.

public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<CancellationToken, Task<TResult>> fallbackAction, Func<DelegateResult<TResult>, Task> onFallbackAsync)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls onFallbackAsync with details of the handled exception or result; then asynchronously calls fallbackAction and returns its result.

public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, TResult fallbackValue, Func<DelegateResult<TResult>, Context, Task> onFallbackAsync)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls onFallbackAsync with details of the handled exception or result and the execution context; then returns fallbackValue.

public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<Context, CancellationToken, Task<TResult>> fallbackAction, Func<DelegateResult<TResult>, Context, Task> onFallbackAsync)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls onFallbackAsync with details of the handled exception or result and the execution context; then asynchronously calls fallbackAction and returns its result.

public static AsyncFallbackPolicy<TResult> FallbackAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, Context, CancellationToken, Task<TResult>> fallbackAction, Func<DelegateResult<TResult>, Context, Task> onFallbackAsync)

Builds an AsyncFallbackPolicy<T> which provides a fallback value if the main execution fails. Executes the main delegate asynchronously, but if this throws a handled exception or raises a handled result, first asynchronously calls onFallbackAsync with details of the handled exception or result and the execution context; then asynchronously calls fallbackAction and returns its result.