private static async Task StartSync() { if (_isSyncing) { return; } try { Synchronization[] synchronizations; lock (LockObject) { if (_isSyncing) { return; } _isSyncing = true; synchronizations = Synchronizations.Values.ToArray(); } if (_syncProgress != null) { _syncProgress.OnSyncStart(); } foreach (var sync in synchronizations) { await sync.DoSync(_syncProgress); } if (_syncProgress != null) { _syncProgress.OnSyncFinished(); } } catch (Exception ex) { Logger.Error("Error during sync", ex); lock (LockObject) _syncException = ex; } finally { _isSyncing = false; _lastSyncDateTime = DateTime.Now; } }