Пример #1
0
        private async Task SynchronizeAsync()
        {
            await _synchronizationSemaphore.WaitAsync().ConfigureAwait(false);

            try
            {
                await _synchronizer.SynchronizeAsync(_primary, _backup).ConfigureAwait(false);
            }
            finally
            {
                _synchronizationSemaphore.Release();
            }
        }
Пример #2
0
        private async Task Synchronize()
        {
            await _writeSemaphore.WaitAsync();

            try
            {
                if (!IsSynchronized)
                {
                    await _synchronizer.SynchronizeAsync(Source, Cache).ConfigureAwait(false);

                    IsSynchronized       = true;
                    _lastSynchronization = DateTimeOffset.UtcNow;
                }
            }
            finally
            {
                _writeSemaphore.Release();
            }
        }
Пример #3
0
        private async Task CheckSynchronizationAsync()
        {
            await _masterStatusSemaphore.WaitAsync().ConfigureAwait(false);

            try
            {
                if (_isMasterDown)
                {
                    await _synchronizer.SynchronizeAsync(_slave, _master).ConfigureAwait(false);

                    _isMasterDown = false;
                    await RaiseMasterRecoveredAsync().ConfigureAwait(false);
                }
            }
            finally
            {
                _masterStatusSemaphore.Release();
            }
        }