private Task RefreshPlaylist() => Task.Factory.StartNew(() => { lock (_refreshLock) { if (_playlist.Count <= MonitorsManager.MonitorCount * 2) { _logger.Info("Refreshing playlist started"); foreach (var playlistElement in PlaylistManager.GetNext()) { var wallpaper = WallpaperManager.GetById(playlistElement.WallpaperId); if (wallpaper.HasValue) { _playlist.Add(wallpaper.Value); } } } while (_playlistLast.Count > 10) { _playlistLast.RemoveAt(0); } } }).ContinueWith(x => { if (x.IsFaulted) { _logger.Error(x.Exception, "Refreshing playlist failed"); } });