async Task StartSavingChangesInternal() { await TaskEx.Yield(); WaitForFlushIfInProgress(); Log.Info("Reseting session flush event"); unitOfWorkFlashInProgressEvent.Reset(); try { var result = await databaseApi.BulkUpdate(bulk => unitOfWork.ApplyChanges(bulk)); // releasing mutex before locking on unitOfWork to prevent dead lock Log.Info("Setting session flush event due save operation completion"); unitOfWorkFlashInProgressEvent.Set(); lock (unitOfWork) unitOfWork.UpdateRevisions(result.Values); } catch (Exception e) { var aggregateException = e as AggregateException; if (aggregateException != null) { throw aggregateException.Flatten(); } throw; } }
public IDictionary <string, DocumentInfo> BulkUpdate(Action <IBulkUpdateBatch> updateCommandBuilder) { return(databaseApi.BulkUpdate(updateCommandBuilder).WaitForResult()); }