public void SendEvents(IList <Event> eventsToSend, Action <bool> callback) { if (_storage.HasData) { SendOldEvents(); } _eventSender.SendEvents(eventsToSend, isSuccess => { if (isSuccess) { callback(true); } else { _storage.Store(eventsToSend); callback(false); } }); }
private void Flush() { Event[] array; lock (_syncRoot) { _timer?.Dispose(); _timer = null; array = _queue.ToArray(); _queue.Clear(); } _sender.SendEvents(array, isSuccess => { }); }
public async Task Commit() { if (ManagedObject == null) { throw new Exception(); } using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { _eventSender.SendEvents(ManagedObject.GetEventsToSend()); ManagedObject.ClearEvents(); if (ManagedObject.State != EntityState.Unchanged) { await _repository.Save(ManagedObject); } await _distributedCache.AddOrUpdateEntry(_distributedCacheEntryOptions, CacheKey, ManagedObject); transaction.Complete(); } }