예제 #1
0
        private async Task <T> RetryAsync <T>(Func <Task <T> > act, int maxCount = 3)
        {
            Exception ex;

            do
            {
                try
                {
                    return(await act());
                }
                catch (Exception e)
                {
                    ex = e;
                    _log.Warn(e, "Got error on trying to execute a sql journal method, will retry");
                }
            } while (SqlAzureRetriableExceptionDetector.ShouldRetryOn(ex) && --maxCount > 0);
            _log.Error(ex, "Got fatal error trying to execute a sql journal method");
            ExceptionDispatchInfo.Capture(ex).Throw();
            //never reach this statement
            throw new InvalidOperationException();
        }
예제 #2
0
        private async Task RetryAsync(Func <Task> act, int maxCount = 3)
        {
            Exception ex;

            do
            {
                try
                {
                    await act();

                    return;
                }
                catch (Exception e)
                {
                    ex = e;
                    _log.Warn(e, "Got error on trying to execute a sql journal method, will retry");
                }
            } while (SqlAzureRetriableExceptionDetector.ShouldRetryOn(ex) && --maxCount > 0);

            _log.Error(ex, "Got fatal error trying to execute a sql journal method");
            ExceptionDispatchInfo.Capture(ex).Throw();
        }