public async Task Complete() { var toSkip = new HashSet <DocumentBase>(DocumentBaseEqualityComparer.Instance); while (_identityMap .Except(toSkip, DocumentBaseEqualityComparer.Instance) .Any(a => a.Outbox.Any())) { var document = _identityMap .Except(toSkip, DocumentBaseEqualityComparer.Instance) .FirstOrDefault(a => a.Outbox.Any()); if (document == null) { continue; } var ex = await _dispatcher.Dispatch(document); if (ex != null) { toSkip.Add(document); await _offlineDispatcher.DispatchOffline(document); } } }
public async Task Complete() { var toSkip = new HashSet <DocumentBase>(DocumentBaseEqualityComparer.Instance); while (TryGetDocumentWithOutboxMessages(toSkip, out var document)) { var ex = await _dispatcher.Dispatch(document); if (ex != null) { toSkip.Add(document); await _offlineDispatcher.DispatchOffline(document); } } }