RetryPolicy<TResult>
A retry policy that can be applied to synchronous delegates returning a value of type TResult.
            
                using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Polly.Retry
{
    [System.Runtime.CompilerServices.NullableContext(1)]
    [System.Runtime.CompilerServices.Nullable(new byte[] {
        0,
        1
    })]
    public class RetryPolicy<[System.Runtime.CompilerServices.Nullable(2)] TResult> : Policy<TResult>, IRetryPolicy<TResult>, IRetryPolicy, IsPolicy
    {
        private readonly Action<DelegateResult<TResult>, TimeSpan, int, Context> _onRetry;
        private readonly int _permittedRetryCount;
        [System.Runtime.CompilerServices.Nullable(2)]
        private readonly IEnumerable<TimeSpan> _sleepDurationsEnumerable;
        [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            1,
            1,
            1
        })]
        private readonly Func<int, DelegateResult<TResult>, Context, TimeSpan> _sleepDurationProvider;
        internal RetryPolicy(PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry, int permittedRetryCount = int.MaxValue, [System.Runtime.CompilerServices.Nullable(2)] IEnumerable<TimeSpan> sleepDurationsEnumerable = null, [System.Runtime.CompilerServices.Nullable(new byte[] {
            2,
            1,
            1,
            1
        })] Func<int, DelegateResult<TResult>, Context, TimeSpan> sleepDurationProvider = null)
            : base(policyBuilder)
        {
            _permittedRetryCount = permittedRetryCount;
            _sleepDurationsEnumerable = sleepDurationsEnumerable;
            _sleepDurationProvider = sleepDurationProvider;
            _onRetry = onRetry;
        }
        [DebuggerStepThrough]
        protected override TResult Implementation(Func<Context, CancellationToken, TResult> action, Context context, CancellationToken cancellationToken)
        {
            if (action == null)
                throw new ArgumentNullException("action");
            return RetryEngine.Implementation<TResult>(action, context, base.ExceptionPredicates, base.ResultPredicates, _onRetry, cancellationToken, _permittedRetryCount, _sleepDurationsEnumerable, _sleepDurationProvider);
        }
    }
}