Interface IAsyncPolicy
- Namespace
 - Polly
 
- Assembly
 - Polly.dll
 
An interface defining all executions available on a non-generic, asynchronous policy
public interface IAsyncPolicy : IsPolicy
  - Inherited Members
 
Methods
ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
- Task<PolicyResult>
 The captured result
Exceptions
- ArgumentNullException
 contextData
ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult>
 The captured result
Exceptions
- ArgumentNullException
 contextData
ExecuteAndCaptureAsync(Func<Context, Task>, Context)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, Context context)
  Parameters
actionFunc<Context, Task>The action to perform.
contextContextContext data that is passed to the exception policy.
Returns
- Task<PolicyResult>
 The captured result
ExecuteAndCaptureAsync(Func<Context, Task>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, IDictionary<string, object> contextData)
  Parameters
actionFunc<Context, Task>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<PolicyResult>
 The captured result
Exceptions
- ArgumentNullException
 contextData
ExecuteAndCaptureAsync(Func<CancellationToken, Task>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken)
  Parameters
actionFunc<CancellationToken, Task>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
ExecuteAndCaptureAsync(Func<CancellationToken, Task>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<CancellationToken, Task>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAndCaptureAsync(Func<Task>)
Executes the specified asynchronous action within the policy and returns the captured result.
Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action)
  Parameters
Returns
- Task<PolicyResult>
 The captured result
ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextContextA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
Exceptions
- ArgumentNullException
 contextData
ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
Exceptions
- ArgumentNullException
 contextData
ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>>, Context)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>> action, Context context)
  Parameters
actionFunc<Context, Task<TResult>>The action to perform.
contextContextContext data that is passed to the exception policy.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>> action, IDictionary<string, object> contextData)
  Parameters
actionFunc<Context, Task<TResult>>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
Exceptions
- ArgumentNullException
 contextData
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken)
  Parameters
actionFunc<CancellationToken, Task<TResult>>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<CancellationToken, Task<TResult>>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>>)
Executes the specified asynchronous action within the policy and returns the result.
Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action)
  Parameters
Returns
- Task<PolicyResult<TResult>>
 The captured result
Type Parameters
TResultThe type of the result.
ExecuteAsync(Func<Context, CancellationToken, Task>, Context, CancellationToken)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
ExecuteAsync(Func<Context, CancellationToken, Task>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAsync(Func<Context, CancellationToken, Task>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
ExecuteAsync(Func<Context, CancellationToken, Task>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
Exceptions
- ArgumentNullException
 contextData
ExecuteAsync(Func<Context, Task>, Context)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Context, Task> action, Context context)
  Parameters
actionFunc<Context, Task>The action to perform.
contextContextContext data that is passed to the exception policy.
Returns
ExecuteAsync(Func<Context, Task>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Context, Task> action, IDictionary<string, object> contextData)
  Parameters
actionFunc<Context, Task>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
ExecuteAsync(Func<CancellationToken, Task>, CancellationToken)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken)
  Parameters
actionFunc<CancellationToken, Task>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
ExecuteAsync(Func<CancellationToken, Task>, CancellationToken, bool)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<CancellationToken, Task>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAsync(Func<Task>)
Executes the specified asynchronous action within the policy.
Task ExecuteAsync(Func<Task> action)
  Parameters
Returns
ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResultThe type of the result.
ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextContextContext data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResultThe type of the result.
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResult
ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<Context, CancellationToken, Task<TResult>>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResult
Exceptions
- ArgumentNullException
 contextData
ExecuteAsync<TResult>(Func<Context, Task<TResult>>, Context)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action, Context context)
  Parameters
actionFunc<Context, Task<TResult>>The action to perform.
contextContextContext data that is passed to the exception policy.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResultThe type of the result.
ExecuteAsync<TResult>(Func<Context, Task<TResult>>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action, IDictionary<string, object> contextData)
  Parameters
actionFunc<Context, Task<TResult>>The action to perform.
contextDataIDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResult
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken)
  Parameters
actionFunc<CancellationToken, Task<TResult>>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResultThe type of the result.
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
  Parameters
actionFunc<CancellationToken, Task<TResult>>The action to perform.
cancellationTokenCancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
continueOnCapturedContextboolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResultThe type of the result.
Exceptions
- InvalidOperationException
 Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAsync<TResult>(Func<Task<TResult>>)
Executes the specified asynchronous action within the policy and returns the result.
Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action)
  Parameters
Returns
- Task<TResult>
 The value returned by the action
Type Parameters
TResultThe type of the result.
WithPolicyKey(string)
Sets the PolicyKey for this Policy instance.
IAsyncPolicy WithPolicyKey(string policyKey)