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

RetryPolicyState<TResult>

class RetryPolicyState<TResult> : IRetryPolicyState<TResult>
using System; using System.Threading; using System.Threading.Tasks; namespace Polly.Retry { internal class RetryPolicyState<TResult> : IRetryPolicyState<TResult> { private readonly Func<DelegateResult<TResult>, Context, Task> _onRetryAsync; private readonly Action<DelegateResult<TResult>, Context> _onRetry; private readonly Context _context; public RetryPolicyState(Func<DelegateResult<TResult>, Context, Task> onRetryAsync, Context context) { _onRetryAsync = onRetryAsync; _context = context; } public async Task<bool> CanRetryAsync(DelegateResult<TResult> delegateResult, CancellationToken ct, bool continueOnCapturedContext) { await this._onRetryAsync(delegateResult, this._context).ConfigureAwait(continueOnCapturedContext); return true; } public RetryPolicyState(Action<DelegateResult<TResult>, Context> onRetry, Context context) { _onRetry = onRetry; _context = context; } public bool CanRetry(DelegateResult<TResult> delegateResult, CancellationToken cancellationToken) { _onRetry(delegateResult, _context); return true; } } }