public void MoveClockForward(TimeSpan span) { CurrentUtcDateTime = CurrentUtcDateTime.AddTicks(span.Ticks); while (true) { dynamic timerInfo = null; lock (timersLock) { timerInfo = timers.FirstOrDefault(); } if (timerInfo == null) { break; } if (timerInfo.FireAt > CurrentUtcDateTime) { break; } lock (timersLock) { timers.Remove(timerInfo); } timerInfo.TaskCompletionSource.SetResult(null); } }
async Task <TResult> CallSubOrchestratorWithRetryAsync <TResult>(string functionName, RetryOptions retryOptions, string instanceId, object input, DateTime firstAttempt, int attempt) { try { return(await CallSubOrchestratorAsync <TResult>(functionName, instanceId, input)); } catch (Exception ex) { var nextDelay = ComputeNextDelay(attempt, firstAttempt, ex, retryOptions); if (!nextDelay.HasValue) { throw; } History.Add(new GenericEvent(History.Count, $"Delaying {nextDelay.Value.TotalSeconds:0.###} seconds before retry attempt {attempt} for {functionName}")); if (nextDelay.Value > TimeSpan.Zero) { await CreateTimer(CurrentUtcDateTime.Add(nextDelay.Value), (object)null, CancellationToken.None); } return(await CallActivityWithRetryAsync <TResult>(functionName, retryOptions, input, firstAttempt, attempt + 1)); } }