Exemple #1
0
        public virtual async Task <int> SaveAsync()
        {
            await threadSafety.WaitAsync().ConfigureAwait(false);

            try
            {
                await Task.WhenAll(markingTasks).ConfigureAwait(false);

                markingTasks.Clear();
                return(await dataWriterAdapter.SaveAsync().ConfigureAwait(false));
            }
            finally
            {
                threadSafety.Release();
            }
        }
        public virtual async Task <int> SaveAsync()
        {
            if (saveInProgress)
            {
                throw new InvalidOperationException("A save operation is currently in progress on this repository instance. You'll have to wait before doing a new one on the same repository or add more operation in the same unit of work scope.");
            }
            saveInProgress = true;
            try
            {
                await Task.WhenAll(markingTasks);

                markingTasks.Clear();
                return(await dataWriterAdapter.SaveAsync().ConfigureAwait(false));
            }
            finally
            {
                saveInProgress = false;
            }
        }