protected bool WaitUntilAllEventsProcessedBy(IEventRegistry eventRegistry, string subscriptionName, TimeSpan timeout) { var timeoutTime = DateTime.Now.Add(timeout); var latestEventId = eventRegistry.GetLatestEventId(); while (eventRegistry.GetCurrentEventId(subscriptionName) < latestEventId) { if (DateTime.Now >= timeoutTime) { return(false); } Thread.Sleep(100); } return(true); }