async private Task <IImmutableList <Exception> > WriteTask(IEnumerable <AtomicWrite> messages) { // Exception accumulator List <Exception> exceptions = new List <Exception>(); await Task.Run(() => { foreach (AtomicWrite m in messages) { IEnumerable <IPersistentRepresentation> messagePayload = m.Payload as IEnumerable <IPersistentRepresentation>; if (messagePayload.ToImmutableArray().Length != 1) { exceptions.Add(new NotSupportedException("Couchbase does not support multiple writes.")); continue; } try { foreach (IPersistentRepresentation item in messagePayload) { Document <JournalEntry> jED = ToJournalEntry(item); _CBBucket.InsertAsync <JournalEntry>(jED); } } catch (Exception ex) { exceptions.Add(ex); } } }); return(exceptions.ToImmutableList <Exception>()); }
async private Task WriteMessagesTask(IEnumerable <IPersistentRepresentation> messages) { await Task.Run(() => { foreach (IPersistentRepresentation m in messages) { Document <JournalEntry> jED = ToJournalEntry(m); _CBBucket.InsertAsync <JournalEntry>(jED); } }); }