public async Task WaitUntilProcessed(CommandProcessingResult result, TimeSpan timeout) { if (!result.EventsWereEmitted) { return; } var mostRecentGlobalSequenceNumber = result.GetNewPosition(); var stopwatch = Stopwatch.StartNew(); var currentPosition = await GetPosition(canGetFromCache : true); while (currentPosition < mostRecentGlobalSequenceNumber) { if (stopwatch.Elapsed > timeout) { throw new TimeoutException(string.Format("View for {0} did not catch up to {1} within {2} timeout!", typeof(TViewInstance), mostRecentGlobalSequenceNumber, timeout)); } await Task.Delay(TimeSpan.FromMilliseconds(20)); currentPosition = await GetPosition(canGetFromCache : false); } }
public async Task WaitUntilProcessed(CommandProcessingResult result, TimeSpan timeout) { if (!result.EventsWereEmitted) { return; } while (_position < result.GetNewPosition()) { await Task.Delay(100); } }
public async Task WaitUntilProcessed(CommandProcessingResult result, TimeSpan timeout) { if (!result.EventsWereEmitted) { return; } var stopwatch = Stopwatch.StartNew(); while (_position < result.GetNewPosition()) { await Task.Delay(100); if (stopwatch.Elapsed > timeout) { throw new TimeoutException(string.Format("oh noes, the view did not catch up within {0} timeout!", timeout)); } } }