protected Result CheckIfShouldRevive(ServiceStatusInformation serviceInfo, out bool shouldRevive, out TimeSpan?secondsToWait)
        {
            shouldRevive  = false;
            secondsToWait = null;

            // This is not likely to ever happen, without significant rewrites.
            if (serviceInfo == null)
            {
                return(Result.SingleFatal(Fatals.KeepAliveServicePassedNullService));
            }

            // Try, if it has never been tried before.
            DateTime?lastAttempt;

            if ((lastAttempt = serviceInfo.LastAttempt) == null)
            {
                shouldRevive = true;
                return(Result.Success);
            }

            Result check;

            if (!(check = GetRevivalTimespan(serviceInfo, out secondsToWait)))
            {
                return(check);
            }

            var timePassed = DateTime.Now - lastAttempt.Value;

            shouldRevive = timePassed >= secondsToWait;

            return(check);
        }
        protected Result GetRevivalTimespan(ServiceStatusInformation serviceInfo, out TimeSpan?secondsToWait)
        {
            secondsToWait = TimeSpan.FromTicks(long.MaxValue);

            // This is not likely to ever happen, without significant rewrites.
            if (serviceInfo == null)
            {
                return(Result.SingleFatal(Fatals.KeepAliveServicePassedNullService));
            }

            const int    baseSeconds = 5;
            const double growthRate  = 1.2;
            var          attempts    = serviceInfo.FailedAttempts;

            var multiplier = Math.Pow(growthRate, attempts);

            secondsToWait = TimeSpan.FromSeconds(baseSeconds * multiplier);

            return(Result.Success);
        }