private async void PersistCache(object state) { _timer.Change(Timeout.Infinite, Timeout.Infinite); try { var pairs = _cacheService.GetAll(); await _repository.Write(pairs); } catch (Exception ex) { await _log.WriteErrorAsync(Constants.ComponentName, null, null, ex); } finally { _timer.Change(_settings.CacheSettings.PersistPeriod, Timeout.InfiniteTimeSpan); } }