Example #1
0
 public override async Task <object> ExecuteInnerAsync(object[] arguments)
 {
     _semaphoreSlim.Wait();
     try
     {
         return(await _funcBase.ExecuteInnerAsync(arguments));
     }
     finally
     {
         _semaphoreSlim.Release();
     }
 }
Example #2
0
        public override async Task <object> ExecuteInnerAsync(object[] arguments)
        {
            TimeSpan rateLimtDelay;

            while ((rateLimtDelay = await GetTimeToNextExecutionAsync(arguments)).Ticks > 0)
            {
                ExecutionDelayed?.Invoke(this, arguments);
                await Task.Delay(rateLimtDelay);
            }

            return(await _funcBase.ExecuteInnerAsync(arguments));
        }
Example #3
0
        private async Task <object> ExecuteInnerAsync(object[] arguments, int currentRetryCount)
        {
            try
            {
                var result = await _funcBase.ExecuteInnerAsync(arguments);

                if (_retryOnResult(result) && currentRetryCount < _maxRetryCount)
                {
                    return(await ExecuteInnerAsync(arguments, currentRetryCount + 1));
                }
                return(result);
            }
            catch (Exception exce)
            {
                if (_retryOnException(exce) && currentRetryCount < _maxRetryCount)
                {
                    return(await ExecuteInnerAsync(arguments, currentRetryCount + 1));
                }
                throw;
            }
        }