private async void SynchronizeDb() { var accounts = (await AccountProxy.GetAccountsAsync().ConfigureAwait(false)).ToArray(); var registered = _accountCache.Keys.ToArray(); var news = registered.Except(accounts).ToArray(); var olds = accounts.Except(registered).ToArray(); await Task.Run(() => Task.WaitAll( olds.Select(AccountProxy.RemoveAccountAsync) .Concat(news.Select(AccountProxy.AddAccountAsync)) .ToArray())).ConfigureAwait(false); }