private async Task ProccessEvents() { List <LocalIntegrationEvent> localIntegrationEvents = await _backgroundTaskLocalIntegrationEventService.GetAllReadyToPulishAndUpdateTheirStatuses(); foreach (var @event in localIntegrationEvents) { object obj = @event.JsonBoby.DeserializeJson(); var messageId = @event.UniqueId; messageId = await _endpoint.Publish(obj, messageId).ConfigureAwait(false); @event.UniqueId = messageId; @event.Status = (int)EnumLocalIntegrationEventStatus.Published; await _backgroundTaskLocalIntegrationEventService.UpdateAsync(@event); } }