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

RetryPolicyStateWithCount<TResult>

class RetryPolicyStateWithCount<TResult> : IRetryPolicyState<TResult>
using System; namespace Polly.Retry { internal class RetryPolicyStateWithCount<TResult> : IRetryPolicyState<TResult> { private int _errorCount; private readonly int _retryCount; private readonly Action<DelegateResult<TResult>, int, Context> _onRetry; private readonly Context _context; public RetryPolicyStateWithCount(int retryCount, Action<DelegateResult<TResult>, int, Context> onRetry, Context context) { _retryCount = retryCount; _onRetry = onRetry; _context = context; } public RetryPolicyStateWithCount(int retryCount, Action<DelegateResult<TResult>, int> onRetry) : this(retryCount, (Action<DelegateResult<TResult>, int, Context>)delegate(DelegateResult<TResult> delegateResult, int i, Context context) { onRetry(delegateResult, i); }, Context.Empty) { } public bool CanRetry(DelegateResult<TResult> delegateResult) { _errorCount++; bool num = _errorCount <= _retryCount; if (num) _onRetry(delegateResult, _errorCount, _context); return num; } } }