Esempio n. 1
0
        static void Attempt <T>(Composer <T> composer, IRetryContext retryContext, Action <Composer <T> > callback)
        {
            composer.ComposeTask(callback);

            composer.Compensate(compensation =>
            {
                TimeSpan delay;
                if (!retryContext.CanRetry(compensation.Exception, out delay))
                {
                    return(compensation.Throw());
                }

                return(compensation.ComposeTask(x =>
                {
                    x.Delay(delay);

                    Attempt(x, retryContext, callback);
                }));
            });
        }