Beispiel #1
0
 private async Task ExecuteRetryPolicy()
 {
     if (retryPolicy == null || !retryPolicy.ShouldRetry(retryCount, null, out TimeSpan interval))
     {
         retryCount  = 0;
         retryPolicy = new ExponentialBackoff(5, TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(10.0));
     }
     else
     {
         retryCount++;
         await Task.Delay(interval);
     }
 }
        private async Task ExecuteOutputRetryPolicyAsync()

        {
            if (outputPolicy == null || !outputPolicy.ShouldRetry(outputCount, null, out TimeSpan interval))
            {
                outputCount  = 0;
                outputPolicy = new ExponentialBackoff(5, TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(10.0));
            }
            else
            {
                outputCount++;
                await Task.Delay(interval);
            }
        }
Beispiel #3
0
        private void ExecuteOutputRetryPolicy()

        {
            if (outputPolicy == null || !outputPolicy.ShouldRetry(inputCount, null, out TimeSpan interval))
            {
                outputCount  = 0;
                outputPolicy = new ExponentialBackoff(5, TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(2.0));
            }
            else
            {
                outputCount++;
                Task.Delay(interval).Wait();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Returns true if, based on the parameters the operation should be retried.
        /// </summary>
        /// <param name="currentRetryCount">How many times the operation has been retried.</param>
        /// <param name="lastException">Operation exception.</param>
        /// <param name="retryInterval">Next retry should be performed after this time interval.</param>
        /// <returns>True if the operation should be retried, false otherwise.</returns>
        public bool ShouldRetry(int currentRetryCount, Exception lastException, out TimeSpan retryInterval)
        {
            OnRetryError?.Invoke(currentRetryCount, lastException);

            return(_exponentialBackoff.ShouldRetry(currentRetryCount, lastException, out retryInterval));
        }