Class Policy
- Namespace
- Polly
- Assembly
- Polly.dll
Transient exception handling policies that can be applied to delegates
public abstract class Policy : ISyncPolicy, IAsyncPolicy, IsPolicy
- Inheritance
-
Policy
- Implements
- Derived
- Inherited Members
Properties
PolicyKey
A key intended to be unique to each Policy instance, which is passed with executions as the Context.PolicyKey property.
public string PolicyKey { get; }
Property Value
Methods
Bulkhead(int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy Bulkhead(int maxParallelization)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
Bulkhead(int, Action<Context>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy Bulkhead(int maxParallelization, Action<Context> onBulkheadRejected)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
onBulkheadRejected
Action<Context>An action to call, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentNullException
onBulkheadRejected
Bulkhead(int, int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy Bulkhead(int maxParallelization, int maxQueuingActions)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maximum number of actions that may be queuing, waiting for an execution slot.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
Bulkhead(int, int, Action<Context>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy Bulkhead(int maxParallelization, int maxQueuingActions, Action<Context> onBulkheadRejected)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maximum number of actions that may be queuing, waiting for an execution slot.
onBulkheadRejected
Action<Context>An action to call, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentNullException
onBulkheadRejected
BulkheadAsync(int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy BulkheadAsync(int maxParallelization)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
Returns
- BulkheadPolicy
The policy instance.
BulkheadAsync(int, Func<Context, Task>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy BulkheadAsync(int maxParallelization, Func<Context, Task> onBulkheadRejectedAsync)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
onBulkheadRejectedAsync
Func<Context, Task>An action to call asynchronously, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentNullException
onBulkheadRejectedAsync
BulkheadAsync(int, int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy BulkheadAsync(int maxParallelization, int maxQueuingActions)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maximum number of actions that may be queuing, waiting for an execution slot.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
BulkheadAsync(int, int, Func<Context, Task>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy BulkheadAsync(int maxParallelization, int maxQueuingActions, Func<Context, Task> onBulkheadRejectedAsync)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maximum number of actions that may be queuing, waiting for an execution slot.
onBulkheadRejectedAsync
Func<Context, Task>An action to call asynchronously, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
- ArgumentNullException
onBulkheadRejectedAsync
BulkheadAsync<TResult>(int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> BulkheadAsync<TResult>(int maxParallelization)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
BulkheadAsync<TResult>(int, Func<Context, Task>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> BulkheadAsync<TResult>(int maxParallelization, Func<Context, Task> onBulkheadRejectedAsync)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
onBulkheadRejectedAsync
Func<Context, Task>An action to call asynchronously, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentNullException
onBulkheadRejectedAsync
BulkheadAsync<TResult>(int, int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> BulkheadAsync<TResult>(int maxParallelization, int maxQueuingActions)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maxmimum number of actions that may be queuing, waiting for an execution slot.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
- ArgumentNullException
onBulkheadRejectedAsync
BulkheadAsync<TResult>(int, int, Func<Context, Task>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> BulkheadAsync<TResult>(int maxParallelization, int maxQueuingActions, Func<Context, Task> onBulkheadRejectedAsync)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maxmimum number of actions that may be queuing, waiting for an execution slot.
onBulkheadRejectedAsync
Func<Context, Task>An action to call asynchronously, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
- ArgumentNullException
onBulkheadRejectedAsync
Bulkhead<TResult>(int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> Bulkhead<TResult>(int maxParallelization)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
Bulkhead<TResult>(int, Action<Context>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the action is not executed and a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> Bulkhead<TResult>(int maxParallelization, Action<Context> onBulkheadRejected)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
onBulkheadRejected
Action<Context>An action to call, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentNullException
onBulkheadRejected
Bulkhead<TResult>(int, int)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> Bulkhead<TResult>(int maxParallelization, int maxQueuingActions)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maxmimum number of actions that may be queuing, waiting for an execution slot.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
Bulkhead<TResult>(int, int, Action<Context>)
Builds a bulkhead isolation Policy, which limits the maximum concurrency of actions executed through the policy. Imposing a maximum concurrency limits the potential of governed actions, when faulting, to bring down the system.
When an execution would cause the number of actions executing concurrently through the policy to exceed maxParallelization
, the policy allows a further maxQueuingActions
executions to queue, waiting for a concurrent execution slot. When an execution would cause the number of queuing actions to exceed maxQueuingActions
, a BulkheadRejectedException is thrown.
public static BulkheadPolicy<TResult> Bulkhead<TResult>(int maxParallelization, int maxQueuingActions, Action<Context> onBulkheadRejected)
Parameters
maxParallelization
intThe maximum number of concurrent actions that may be executing through the policy.
maxQueuingActions
intThe maxmimum number of actions that may be queuing, waiting for an execution slot.
onBulkheadRejected
Action<Context>An action to call, if the bulkhead rejects execution due to oversubscription.
Returns
- BulkheadPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
maxParallelization;Value must be greater than zero.
- ArgumentOutOfRangeException
maxQueuingActions;Value must be greater than or equal to zero.
- ArgumentNullException
onBulkheadRejected
Cache(ISyncCacheProvider, ITtlStrategy, ICacheKeyStrategy, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
ICacheKeyStrategyThe cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
Cache(ISyncCacheProvider, ITtlStrategy, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
Cache(ISyncCacheProvider, ITtlStrategy, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
Cache(ISyncCacheProvider, ITtlStrategy, Func<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
Cache(ISyncCacheProvider, TimeSpan, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
Cache(ISyncCacheProvider, TimeSpan, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy Cache(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
cacheKeyStrategy
CacheAsync(IAsyncCacheProvider, ITtlStrategy, ICacheKeyStrategy, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
ICacheKeyStrategyThe cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
CacheAsync(IAsyncCacheProvider, ITtlStrategy, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
CacheAsync(IAsyncCacheProvider, ITtlStrategy, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
CacheAsync(IAsyncCacheProvider, ITtlStrategy, Func<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
CacheAsync(IAsyncCacheProvider, TimeSpan, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
CacheAsync(IAsyncCacheProvider, TimeSpan, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a result.
Before executing a delegate returning a result, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy CacheAsync(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy
The policy instance.
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
cacheKeyStrategy
CacheAsync<TResult>(IAsyncCacheProvider, ITtlStrategy, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
CacheAsync<TResult>(IAsyncCacheProvider, ITtlStrategy, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheProvider
CacheAsync<TResult>(IAsyncCacheProvider, TimeSpan, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
CacheAsync<TResult>(IAsyncCacheProvider, TimeSpan, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
cacheProvider
CacheAsync<TResult>(IAsyncCacheProvider<TResult>, ITtlStrategy, ICacheKeyStrategy, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
IAsyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
ICacheKeyStrategyThe cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
CacheAsync<TResult>(IAsyncCacheProvider<TResult>, ITtlStrategy, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
CacheAsync<TResult>(IAsyncCacheProvider<TResult>, ITtlStrategy, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheProvider
CacheAsync<TResult>(IAsyncCacheProvider<TResult>, ITtlStrategy, Func<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
IAsyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
CacheAsync<TResult>(IAsyncCacheProvider<TResult>, TimeSpan, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider<TResult> cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProvider<TResult>The cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
CacheAsync<TResult>(IAsyncCacheProvider<TResult>, TimeSpan, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
provides a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> CacheAsync<TResult>(IAsyncCacheProvider<TResult> cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
IAsyncCacheProvider<TResult>The cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
cacheProvider
Cache<TResult>(ISyncCacheProvider, ITtlStrategy, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
Cache<TResult>(ISyncCacheProvider, ITtlStrategy, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
Cache<TResult>(ISyncCacheProvider, TimeSpan, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
Cache<TResult>(ISyncCacheProvider, TimeSpan, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProviderThe cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
cacheKeyStrategy
Cache<TResult>(ISyncCacheProvider<TResult>, ITtlStrategy, ICacheKeyStrategy, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, ICacheKeyStrategy cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
ISyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
ICacheKeyStrategyThe cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
Cache<TResult>(ISyncCacheProvider<TResult>, ITtlStrategy, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
Cache<TResult>(ISyncCacheProvider<TResult>, ITtlStrategy, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
Cache<TResult>(ISyncCacheProvider<TResult>, ITtlStrategy, Func<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string>, Action<Context, string, Exception>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider<TResult> cacheProvider, ITtlStrategy ttlStrategy, Func<Context, string> cacheKeyStrategy, Action<Context, string> onCacheGet, Action<Context, string> onCacheMiss, Action<Context, string> onCachePut, Action<Context, string, Exception> onCacheGetError, Action<Context, string, Exception> onCachePutError)
Parameters
cacheProvider
ISyncCacheProvider<TResult>The cache provider.
ttlStrategy
ITtlStrategyA strategy for specifying ttl for values to be cached.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheGet
Action<Context, string>Delegate to call on a cache hit, when value is returned from cache.
onCacheMiss
Action<Context, string>Delegate to call on a cache miss.
onCachePut
Action<Context, string>Delegate to call on cache put.
onCacheGetError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from the cache, passing the execution context, the cache key, and the exception.
onCachePutError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to put a value in the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
ttlStrategy
- ArgumentNullException
cacheKeyStrategy
- ArgumentNullException
onCacheGet
- ArgumentNullException
onCacheMiss
- ArgumentNullException
onCachePut
- ArgumentNullException
onCacheGetError
- ArgumentNullException
onCachePutError
Cache<TResult>(ISyncCacheProvider<TResult>, TimeSpan, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key specified by Context.ExecutionKey.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider<TResult> cacheProvider, TimeSpan ttl, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProvider<TResult>The cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
Cache<TResult>(ISyncCacheProvider<TResult>, TimeSpan, Func<Context, string>, Action<Context, string, Exception>)
Builds a Policy that will function like a result cache for delegate executions returning a TResult
.
Before executing a delegate, checks whether the cacheProvider
holds a value for the cache key determined by applying the cacheKeyStrategy
to the execution Context.
If the cacheProvider
contains a value, returns that value and does not execute the governed delegate. If the cacheProvider
does not provide a value, executes the governed delegate, stores the value with the cacheProvider
, then returns the value.
public static CachePolicy<TResult> Cache<TResult>(ISyncCacheProvider<TResult> cacheProvider, TimeSpan ttl, Func<Context, string> cacheKeyStrategy, Action<Context, string, Exception> onCacheError = null)
Parameters
cacheProvider
ISyncCacheProvider<TResult>The cache provider.
ttl
TimeSpanDuration (ttl) for which to cache values.
cacheKeyStrategy
Func<Context, string>The cache key strategy.
onCacheError
Action<Context, string, Exception>Delegate to call if an exception is thrown when attempting to get a value from or put a value into the cache, passing the execution context, the cache key, and the exception.
Returns
- CachePolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
cacheProvider
- ArgumentNullException
cacheKeyStrategy
Execute(Action)
Executes the specified action within the policy.
public void Execute(Action action)
Parameters
action
ActionThe action to perform.
Execute(Action, Context)
Executes the specified action within the policy.
public void Execute(Action action, Context context)
Parameters
action
ActionThe action to perform.
context
ContextContext data that is passed to the exception policy.
Execute(Action, IDictionary<string, object>)
Executes the specified action within the policy.
public void Execute(Action action, IDictionary<string, object> contextData)
Parameters
action
ActionThe action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Execute(Action<Context, CancellationToken>, Context, CancellationToken)
Executes the specified action within the policy.
public void Execute(Action<Context, CancellationToken> action, Context context, CancellationToken cancellationToken)
Parameters
action
Action<Context, CancellationToken>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Execute(Action<Context, CancellationToken>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy.
public void Execute(Action<Context, CancellationToken> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Action<Context, CancellationToken>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Exceptions
- ArgumentNullException
contextData
Execute(Action<Context>, Context)
Executes the specified action within the policy.
public void Execute(Action<Context> action, Context context)
Parameters
action
Action<Context>The action to perform.
context
ContextContext data that is passed to the exception policy.
Execute(Action<Context>, IDictionary<string, object>)
Executes the specified action within the policy.
public void Execute(Action<Context> action, IDictionary<string, object> contextData)
Parameters
action
Action<Context>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Execute(Action<CancellationToken>, Context, CancellationToken)
Executes the specified action within the policy.
public void Execute(Action<CancellationToken> action, Context context, CancellationToken cancellationToken)
Parameters
action
Action<CancellationToken>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Execute(Action<CancellationToken>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy.
public void Execute(Action<CancellationToken> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Action<CancellationToken>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Exceptions
- ArgumentNullException
contextData
Execute(Action<CancellationToken>, CancellationToken)
public void Execute(Action<CancellationToken> action, CancellationToken cancellationToken)
Parameters
action
Action<CancellationToken>cancellationToken
CancellationToken
ExecuteAndCapture(Action)
Executes the specified action within the policy and returns the captured result
public PolicyResult ExecuteAndCapture(Action action)
Parameters
action
ActionThe action to perform.
Returns
- PolicyResult
The captured result
ExecuteAndCapture(Action, Context)
Executes the specified action within the policy and returns the captured result.
public PolicyResult ExecuteAndCapture(Action action, Context context)
Parameters
action
ActionThe action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- PolicyResult
The captured result
ExecuteAndCapture(Action, IDictionary<string, object>)
Executes the specified action within the policy and returns the captured result.
public PolicyResult ExecuteAndCapture(Action action, IDictionary<string, object> contextData)
Parameters
action
ActionThe action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- PolicyResult
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture(Action<Context, CancellationToken>, Context, CancellationToken)
Executes the specified action within the policy and returns the captured result
public PolicyResult ExecuteAndCapture(Action<Context, CancellationToken> action, Context context, CancellationToken cancellationToken)
Parameters
action
Action<Context, CancellationToken>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult
The captured result
ExecuteAndCapture(Action<Context, CancellationToken>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy and returns the captured result.
public PolicyResult ExecuteAndCapture(Action<Context, CancellationToken> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Action<Context, CancellationToken>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture(Action<Context>, Context)
Executes the specified action within the policy and returns the captured result.
public PolicyResult ExecuteAndCapture(Action<Context> action, Context context)
Parameters
action
Action<Context>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- PolicyResult
The captured result
ExecuteAndCapture(Action<Context>, IDictionary<string, object>)
Executes the specified action within the policy and returns the captured result.
public PolicyResult ExecuteAndCapture(Action<Context> action, IDictionary<string, object> contextData)
Parameters
action
Action<Context>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- PolicyResult
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture(Action<CancellationToken>, Context, CancellationToken)
Executes the specified action within the policy and returns the captured result
public PolicyResult ExecuteAndCapture(Action<CancellationToken> action, Context context, CancellationToken cancellationToken)
Parameters
action
Action<CancellationToken>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult
The captured result
ExecuteAndCapture(Action<CancellationToken>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy and returns the captured result.
public PolicyResult ExecuteAndCapture(Action<CancellationToken> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Action<CancellationToken>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture(Action<CancellationToken>, CancellationToken)
Executes the specified action within the policy and returns the captured result
public PolicyResult ExecuteAndCapture(Action<CancellationToken> action, CancellationToken cancellationToken)
Parameters
action
Action<CancellationToken>The action to perform.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult
The captured result
ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, Context context)
Parameters
action
Func<Context, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- Task<PolicyResult>
The captured result
ExecuteAndCaptureAsync(Func<Context, Task>, Context, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, IDictionary<string, object> contextData)
Parameters
action
Func<Context, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<PolicyResult>
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync(Func<Context, Task>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Context, Task> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult>
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync(Func<CancellationToken, Task>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
Exceptions
- InvalidOperationException
Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAndCaptureAsync(Func<CancellationToken, Task>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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<CancellationToken, Task>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task>The action to perform.
cancellationToken
CancellationTokenA 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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task>The action to perform.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action)
Parameters
Returns
- Task<PolicyResult>
The captured result
ExecuteAndCaptureAsync(Func<Task>, Context)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action, Context context)
Parameters
action
Func<Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- Task<PolicyResult>
The captured result
ExecuteAndCaptureAsync(Func<Task>, Context, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult>
The captured result
ExecuteAndCaptureAsync(Func<Task>, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action, bool continueOnCapturedContext)
Parameters
action
Func<Task>The action to perform.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult>
The captured result
ExecuteAndCaptureAsync(Func<Task>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action, IDictionary<string, object> contextData)
Parameters
action
Func<Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<PolicyResult>
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync(Func<Task>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy and returns the captured result.
public Task<PolicyResult> ExecuteAndCaptureAsync(Func<Task> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult>
The captured result
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
context
ContextA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
cancellationToken
CancellationTokenA 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
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>> action, Context context)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>>, Context, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>> action, IDictionary<string, object> contextData)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Context, Task<TResult>> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
context
ContextA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
cancellationToken
CancellationTokenA 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
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- InvalidOperationException
Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
cancellationToken
CancellationTokenA 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
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The 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.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action)
Parameters
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>>, Context)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action, Context context)
Parameters
action
Func<Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>>, Context, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>>, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action, bool continueOnCapturedContext)
Parameters
action
Func<Task<TResult>>The action to perform.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action, IDictionary<string, object> contextData)
Parameters
action
Func<Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<PolicyResult<TResult>> ExecuteAndCaptureAsync<TResult>(Func<Task<TResult>> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<PolicyResult<TResult>>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture<TResult>(Func<Context, CancellationToken, TResult>, Context, CancellationToken)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
ExecuteAndCapture<TResult>(Func<Context, CancellationToken, TResult>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<Context, CancellationToken, TResult> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture<TResult>(Func<Context, TResult>, Context)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<Context, TResult> action, Context context)
Parameters
action
Func<Context, TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture<TResult>(Func<Context, TResult>, IDictionary<string, object>)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<Context, TResult> action, IDictionary<string, object> contextData)
Parameters
action
Func<Context, TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture<TResult>(Func<CancellationToken, TResult>, Context, CancellationToken)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
ExecuteAndCapture<TResult>(Func<CancellationToken, TResult>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<CancellationToken, TResult> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture<TResult>(Func<CancellationToken, TResult>, CancellationToken)
Executes the specified action within the policy and returns the captured result
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<CancellationToken, TResult> action, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, TResult>The action to perform.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
The type of the t result.
ExecuteAndCapture<TResult>(Func<TResult>)
Executes the specified action within the policy and returns the captured result
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<TResult> action)
Parameters
action
Func<TResult>The action to perform.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
ExecuteAndCapture<TResult>(Func<TResult>, Context)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<TResult> action, Context context)
Parameters
action
Func<TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
Exceptions
- ArgumentNullException
contextData
ExecuteAndCapture<TResult>(Func<TResult>, IDictionary<string, object>)
Executes the specified action within the policy and returns the captured result.
public PolicyResult<TResult> ExecuteAndCapture<TResult>(Func<TResult> action, IDictionary<string, object> contextData)
Parameters
action
Func<TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- PolicyResult<TResult>
The captured result
Type Parameters
TResult
Exceptions
- ArgumentNullException
contextData
ExecuteAsync(Func<Context, CancellationToken, Task>, Context, CancellationToken)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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.
public Task ExecuteAsync(Func<Context, CancellationToken, Task> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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.
public Task ExecuteAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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.
public Task ExecuteAsync(Func<Context, CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
Exceptions
- ArgumentNullException
contextData
ExecuteAsync(Func<Context, Task>, Context)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Context, Task> action, Context context)
Parameters
action
Func<Context, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
ExecuteAsync(Func<Context, Task>, Context, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Context, Task> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
ExecuteAsync(Func<Context, Task>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Context, Task> action, IDictionary<string, object> contextData)
Parameters
action
Func<Context, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
ExecuteAsync(Func<Context, Task>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Context, Task> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
ExecuteAsync(Func<CancellationToken, Task>, Context, CancellationToken)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<CancellationToken, Task> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<CancellationToken, Task> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
Exceptions
- InvalidOperationException
Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAsync(Func<CancellationToken, Task>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<CancellationToken, Task> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
Exceptions
- ArgumentNullException
contextData
ExecuteAsync(Func<CancellationToken, Task>, CancellationToken)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task>The action to perform.
cancellationToken
CancellationTokenA 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.
public Task ExecuteAsync(Func<CancellationToken, Task> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task>The action to perform.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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.
public Task ExecuteAsync(Func<Task> action)
Parameters
Returns
ExecuteAsync(Func<Task>, Context)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Task> action, Context context)
Parameters
action
Func<Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
ExecuteAsync(Func<Task>, Context, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Task> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Task>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
ExecuteAsync(Func<Task>, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Task> action, bool continueOnCapturedContext)
Parameters
action
Func<Task>The action to perform.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
ExecuteAsync(Func<Task>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Task> action, IDictionary<string, object> contextData)
Parameters
action
Func<Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
ExecuteAsync(Func<Task>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy.
public Task ExecuteAsync(Func<Task> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Task>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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
TResult
The 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.
public virtual Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The 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.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<Context, CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action, Context context)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The type of the result.
ExecuteAsync<TResult>(Func<Context, Task<TResult>>, Context, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The 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.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action, IDictionary<string, object> contextData)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
contextData
IDictionary<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<Context, Task<TResult>>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Context, Task<TResult>> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Context, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, Context, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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
TResult
The type of the result.
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, Context, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, Context context, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- InvalidOperationException
Please use asynchronous-defined policies when calling asynchronous ExecuteAsync (and similar) methods.
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA 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<CancellationToken, Task<TResult>>, IDictionary<string, object>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, IDictionary<string, object> contextData, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy in use, also cancels any further retries.
continueOnCapturedContext
boolWhether 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<CancellationToken, Task<TResult>>, CancellationToken)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
cancellationToken
CancellationTokenA 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
TResult
The type of the result.
ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>>, CancellationToken, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> action, CancellationToken cancellationToken, bool continueOnCapturedContext)
Parameters
action
Func<CancellationToken, Task<TResult>>The action to perform.
cancellationToken
CancellationTokenA cancellation token which can be used to cancel the action. When a retry policy is in use, also cancels any further retries.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The 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.
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action)
Parameters
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The type of the result.
ExecuteAsync<TResult>(Func<Task<TResult>>, Context)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action, Context context)
Parameters
action
Func<Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The type of the result.
ExecuteAsync<TResult>(Func<Task<TResult>>, Context, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action, Context context, bool continueOnCapturedContext)
Parameters
action
Func<Task<TResult>>The action to perform.
context
ContextContext data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The type of the result.
ExecuteAsync<TResult>(Func<Task<TResult>>, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action, bool continueOnCapturedContext)
Parameters
action
Func<Task<TResult>>The action to perform.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
The type of the result.
ExecuteAsync<TResult>(Func<Task<TResult>>, IDictionary<string, object>)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action, IDictionary<string, object> contextData)
Parameters
action
Func<Task<TResult>>The action to perform.
contextData
IDictionary<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<Task<TResult>>, IDictionary<string, object>, bool)
Executes the specified asynchronous action within the policy and returns the result.
public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> action, IDictionary<string, object> contextData, bool continueOnCapturedContext)
Parameters
action
Func<Task<TResult>>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
continueOnCapturedContext
boolWhether to continue on a captured synchronization context.
Returns
- Task<TResult>
The value returned by the action
Type Parameters
TResult
Execute<TResult>(Func<Context, CancellationToken, TResult>, Context, CancellationToken)
Executes the specified action within the policy and returns the result.
public virtual TResult Execute<TResult>(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Execute<TResult>(Func<Context, CancellationToken, TResult>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<Context, CancellationToken, TResult> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<Context, CancellationToken, TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
Execute<TResult>(Func<Context, TResult>, Context)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<Context, TResult> action, Context context)
Parameters
action
Func<Context, TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
- ArgumentNullException
contextData
Execute<TResult>(Func<Context, TResult>, IDictionary<string, object>)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<Context, TResult> action, IDictionary<string, object> contextData)
Parameters
action
Func<Context, TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
- ArgumentNullException
contextData
Execute<TResult>(Func<CancellationToken, TResult>, Context, CancellationToken)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Execute<TResult>(Func<CancellationToken, TResult>, IDictionary<string, object>, CancellationToken)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<CancellationToken, TResult> action, IDictionary<string, object> contextData, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
Execute<TResult>(Func<CancellationToken, TResult>, CancellationToken)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<CancellationToken, TResult> action, CancellationToken cancellationToken)
Parameters
action
Func<CancellationToken, TResult>The action to perform.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Execute<TResult>(Func<TResult>)
Executes the specified action within the policy and returns the Result.
public TResult Execute<TResult>(Func<TResult> action)
Parameters
action
Func<TResult>The action to perform.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the Result.
Execute<TResult>(Func<TResult>, Context)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<TResult> action, Context context)
Parameters
action
Func<TResult>The action to perform.
context
ContextContext data that is passed to the exception policy.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
- ArgumentNullException
contextData
Execute<TResult>(Func<TResult>, IDictionary<string, object>)
Executes the specified action within the policy and returns the result.
public TResult Execute<TResult>(Func<TResult> action, IDictionary<string, object> contextData)
Parameters
action
Func<TResult>The action to perform.
contextData
IDictionary<string, object>Arbitrary data that is passed to the exception policy.
Returns
- TResult
The value returned by the action
Type Parameters
TResult
The type of the result.
Exceptions
- ArgumentNullException
contextData
- ArgumentNullException
contextData
HandleResult<TResult>(Func<TResult, bool>)
Specifies the type of return result that this policy can handle with additional filters on the result.
public static PolicyBuilder<TResult> HandleResult<TResult>(Func<TResult, bool> resultPredicate)
Parameters
Returns
- PolicyBuilder<TResult>
The PolicyBuilder instance.
Type Parameters
TResult
The type of return values this policy will handle.
HandleResult<TResult>(TResult)
Specifies the type of return result that this policy can handle, and a result value which the policy will handle.
public static PolicyBuilder<TResult> HandleResult<TResult>(TResult result)
Parameters
result
TResultThe TResult value this policy will handle.
Returns
- PolicyBuilder<TResult>
The PolicyBuilder instance.
Type Parameters
TResult
The type of return values this policy will handle.
Remarks
This policy filter matches the result
value returned using .Equals(), ideally suited for value types such as int and enum. To match characteristics of class return types, consider the overload taking a result predicate.
Handle<TException>()
Specifies the type of exception that this policy can handle.
public static PolicyBuilder Handle<TException>() where TException : Exception
Returns
- PolicyBuilder
The PolicyBuilder instance.
Type Parameters
TException
The type of the exception to handle.
Handle<TException>(Func<TException, bool>)
Specifies the type of exception that this policy can handle with additional filters on this exception type.
public static PolicyBuilder Handle<TException>(Func<TException, bool> exceptionPredicate) where TException : Exception
Parameters
exceptionPredicate
Func<TException, bool>The exception predicate to filter the type of exception this policy can handle.
Returns
- PolicyBuilder
The PolicyBuilder instance.
Type Parameters
TException
The type of the exception.
NoOp()
Builds a NoOp Policy that will execute without any custom behavior.
public static NoOpPolicy NoOp()
Returns
- NoOpPolicy
The policy instance.
NoOpAsync()
Builds a NoOp Policy that will execute without any custom behavior.
public static NoOpPolicy NoOpAsync()
Returns
- NoOpPolicy
The policy instance.
NoOpAsync<TResult>()
Builds a NoOp Policy that will execute without any custom behavior.
public static NoOpPolicy<TResult> NoOpAsync<TResult>()
Returns
- NoOpPolicy<TResult>
The policy instance.
Type Parameters
TResult
The type of return values this policy will handle.
NoOp<TResult>()
Builds a NoOp Policy that will execute without any custom behavior.
public static NoOpPolicy<TResult> NoOp<TResult>()
Returns
- NoOpPolicy<TResult>
The policy instance.
Type Parameters
TResult
The type of return values this policy will handle.
Timeout(Func<Context, TimeSpan>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<Context, TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
Timeout(Func<Context, TimeSpan>, TimeoutStrategy)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
Timeout(Func<Context, TimeSpan>, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout(Func<Context, TimeSpan>, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<Context, TimeSpan> timeoutProvider, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout(Func<TimeSpan>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
Timeout(Func<TimeSpan>, TimeoutStrategy)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
Timeout(Func<TimeSpan>, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout(Func<TimeSpan>, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(Func<TimeSpan> timeoutProvider, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout(int)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(int seconds)
Parameters
seconds
intThe number of seconds after which to timeout.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
Timeout(int, TimeoutStrategy)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
Timeout(int, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(int seconds, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeout
Timeout(int, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(int seconds, Action<Context, TimeSpan, Task> onTimeout)
Parameters
seconds
intThe number of seconds after which to timeout.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeout
Timeout(TimeSpan)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(TimeSpan timeout)
Parameters
timeout
TimeSpanThe timeout.
Returns
- TimeoutPolicy
The policy instance.
Timeout(TimeSpan, TimeoutStrategy)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
Timeout(TimeSpan, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeout
Timeout(TimeSpan, Action<Context, TimeSpan, Task>)
Builds a Policy that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy Timeout(TimeSpan timeout, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeout
TimeSpanThe timeout.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeout
TimeoutAsync(Func<Context, TimeSpan>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<Context, TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync(Func<Context, TimeSpan>, TimeoutStrategy)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync(Func<Context, TimeSpan>, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync(Func<Context, TimeSpan>, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<Context, TimeSpan> timeoutProvider, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync(Func<TimeSpan>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync(Func<TimeSpan>, TimeoutStrategy)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync(Func<TimeSpan>, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync(Func<TimeSpan>, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(Func<TimeSpan> timeoutProvider, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync(int)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(int seconds)
Parameters
seconds
intThe number of seconds after which to timeout.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
TimeoutAsync(int, TimeoutStrategy)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(int seconds, TimeoutStrategy timeoutStrategy)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
TimeoutAsync(int, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(int seconds, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
seconds;Value must be greater than zero.
TimeoutAsync(int, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(int seconds, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
seconds
intThe number of seconds after which to timeout.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
TimeoutAsync(TimeSpan)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(TimeSpan timeout)
Parameters
timeout
TimeSpanThe timeout.
Returns
- TimeoutPolicy
The policy instance.
TimeoutAsync(TimeSpan, TimeoutStrategy)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
TimeoutAsync(TimeSpan, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
TimeoutAsync(TimeSpan, Func<Context, TimeSpan, Task, Task>)
Builds a Policy that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy TimeoutAsync(TimeSpan timeout, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeout
TimeSpanThe timeout.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(Func<Context, TimeSpan>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<Context, TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync<TResult>(Func<Context, TimeSpan>, TimeoutStrategy)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync<TResult>(Func<Context, TimeSpan>, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(Func<Context, TimeSpan>, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<Context, TimeSpan> timeoutProvider, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(Func<TimeSpan>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync<TResult>(Func<TimeSpan>, TimeoutStrategy)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
TimeoutAsync<TResult>(Func<TimeSpan>, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(Func<TimeSpan>, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(Func<TimeSpan> timeoutProvider, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(int)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(int seconds)
Parameters
seconds
intThe number of seconds after which to timeout.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
TimeoutAsync<TResult>(int, TimeoutStrategy)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(int seconds, TimeoutStrategy timeoutStrategy)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
TimeoutAsync<TResult>(int, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(int seconds, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(int, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(int seconds, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
seconds
intThe number of seconds after which to timeout.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(TimeSpan)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(TimeSpan timeout)
Parameters
timeout
TimeSpanThe timeout.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
TimeoutAsync<TResult>(TimeSpan, TimeoutStrategy)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
TimeoutAsync<TResult>(TimeSpan, TimeoutStrategy, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
TimeoutAsync<TResult>(TimeSpan, Func<Context, TimeSpan, Task, Task>)
Builds a Policy<TResult> that will wait asynchronously for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> TimeoutAsync<TResult>(TimeSpan timeout, Func<Context, TimeSpan, Task, Task> onTimeoutAsync)
Parameters
timeout
TimeSpanThe timeout.
onTimeoutAsync
Func<Context, TimeSpan, Task, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeoutAsync
Timeout<TResult>(Func<Context, TimeSpan>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<Context, TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
Timeout<TResult>(Func<Context, TimeSpan>, TimeoutStrategy)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentNullException
timeoutProvider
Timeout<TResult>(Func<Context, TimeSpan>, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<Context, TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout<TResult>(Func<Context, TimeSpan>, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<Context, TimeSpan> timeoutProvider, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<Context, TimeSpan>A function to provide the timeout for this execution.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout<TResult>(Func<TimeSpan>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<TimeSpan> timeoutProvider)
Parameters
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
Timeout<TResult>(Func<TimeSpan>, TimeoutStrategy)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentNullException
timeoutProvider
Timeout<TResult>(Func<TimeSpan>, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<TimeSpan> timeoutProvider, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout<TResult>(Func<TimeSpan>, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(Func<TimeSpan> timeoutProvider, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeoutProvider
Func<TimeSpan>A function to provide the timeout for this execution.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentNullException
timeoutProvider
- ArgumentNullException
onTimeout
Timeout<TResult>(int)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(int seconds)
Parameters
seconds
intThe number of seconds after which to timeout.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
Timeout<TResult>(int, TimeoutStrategy)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(int seconds, TimeoutStrategy timeoutStrategy)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
Timeout<TResult>(int, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(int seconds, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
seconds
intThe number of seconds after which to timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeout
Timeout<TResult>(int, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(int seconds, Action<Context, TimeSpan, Task> onTimeout)
Parameters
seconds
intThe number of seconds after which to timeout.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
seconds;Value must be greater than zero.
- ArgumentNullException
onTimeout
Timeout<TResult>(TimeSpan)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout)
Parameters
timeout
TimeSpanThe timeout.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Timeout<TResult>(TimeSpan, TimeoutStrategy)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentOutOfRangeException
timeout
Timeout<TResult>(TimeSpan, TimeoutStrategy, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, TimeoutStrategy timeoutStrategy, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeout
TimeSpanThe timeout.
timeoutStrategy
TimeoutStrategyThe timeout strategy.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeout
Timeout<TResult>(TimeSpan, Action<Context, TimeSpan, Task>)
Builds a Policy<TResult> that will wait for a delegate to complete for a specified period of time. A TimeoutRejectedException will be thrown if the delegate does not complete within the configured timeout.
public static TimeoutPolicy<TResult> Timeout<TResult>(TimeSpan timeout, Action<Context, TimeSpan, Task> onTimeout)
Parameters
timeout
TimeSpanThe timeout.
onTimeout
Action<Context, TimeSpan, Task>An action to call on timeout, passing the execution context, the timeout applied, and a Task<TResult> capturing the abandoned, timed-out action.
The Task parameter will be null if the executed action responded co-operatively to cancellation before the policy timed it out.
Returns
- TimeoutPolicy<TResult>
The policy instance.
Type Parameters
TResult
Exceptions
- ArgumentOutOfRangeException
timeout;Value must be greater than zero.
- ArgumentNullException
onTimeout
WithPolicyKey(string)
Sets the PolicyKey for this Policy instance.
public Policy WithPolicyKey(string policyKey)
Parameters
Returns
Wrap(Policy)
Wraps the specified inner policy.
public PolicyWrap Wrap(Policy innerPolicy)
Parameters
innerPolicy
PolicyThe inner policy.
Returns
- PolicyWrap
PolicyWrap.PolicyWrap.
Wrap(params Policy[])
Creates a PolicyWrap of the given policies.
public static PolicyWrap Wrap(params Policy[] policies)
Parameters
policies
Policy[]The policies to place in the wrap, outermost (at left) to innermost (at right).
Returns
- PolicyWrap
The PolicyWrap.
Exceptions
- ArgumentException
The enumerable of policies to form the wrap must contain at least two policies.
WrapAsync(Policy)
Wraps the specified inner policy.
public PolicyWrap WrapAsync(Policy innerPolicy)
Parameters
innerPolicy
PolicyThe inner policy.
Returns
- PolicyWrap
PolicyWrap.PolicyWrap.
WrapAsync(params Policy[])
Creates a PolicyWrap of the given policies.
public static PolicyWrap WrapAsync(params Policy[] policies)
Parameters
policies
Policy[]The policies to place in the wrap, outermost (at left) to innermost (at right).
Returns
- PolicyWrap
The PolicyWrap.
Exceptions
- ArgumentException
The enumerable of policies to form the wrap must contain at least two policies.
WrapAsync<TResult>(Policy<TResult>)
Wraps the specified inner policy.
public PolicyWrap<TResult> WrapAsync<TResult>(Policy<TResult> innerPolicy)
Parameters
innerPolicy
Policy<TResult>The inner policy.
Returns
- PolicyWrap<TResult>
PolicyWrap.PolicyWrap.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
WrapAsync<TResult>(params Policy<TResult>[])
Creates a PolicyWrap of the given policies governing delegates returning values of type TResult
.
public static PolicyWrap<TResult> WrapAsync<TResult>(params Policy<TResult>[] policies)
Parameters
policies
Policy<TResult>[]The policies to place in the wrap, outermost (at left) to innermost (at right).
Returns
- PolicyWrap<TResult>
The PolicyWrap.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentException
The enumerable of policies to form the wrap must contain at least two policies.
Wrap<TResult>(Policy<TResult>)
Wraps the specified inner policy.
public PolicyWrap<TResult> Wrap<TResult>(Policy<TResult> innerPolicy)
Parameters
innerPolicy
Policy<TResult>The inner policy.
Returns
- PolicyWrap<TResult>
PolicyWrap.PolicyWrap.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Wrap<TResult>(params Policy<TResult>[])
Creates a PolicyWrap of the given policies governing delegates returning values of type TResult
.
public static PolicyWrap<TResult> Wrap<TResult>(params Policy<TResult>[] policies)
Parameters
policies
Policy<TResult>[]The policies to place in the wrap, outermost (at left) to innermost (at right).
Returns
- PolicyWrap<TResult>
The PolicyWrap.
Type Parameters
TResult
The return type of delegates which may be executed through the policy.
Exceptions
- ArgumentException
The enumerable of policies to form the wrap must contain at least two policies.