Example #1
0
 private void PerformBuildCache()
 {
     _logger.Info("Scanning for the first time");
     _trackRepository.AddAll(_apiAdapter.GetTracks());
     _cacheInfoRepository.Update(new CacheInfo {
         TracksUpdated = DateTime.Now
     });
     _logger.Info($"Cache contains {_trackRepository.Count()} tracks.");
     _semaphore.Release();
 }
Example #2
0
 private void BuildCache()
 {
     Semaphore.Wait();
     Task.Factory.StartNew(() =>
     {
         _logger.Info("Scanning for the first time");
         _trackRepository.AddAll(_apiAdapter.GetTracks());
         _cacheInfoRepository.Update(new CacheInfo {
             TracksUpdated = DateTime.Now
         });
         _logger.Info($"Cache contains {_trackRepository.Count()} tracks.");
         Semaphore.Release();
     }, TaskCreationOptions.PreferFairness);
 }