public void GetSongsOnDevice(object state) { Dictionary<string, AnalyzedSong> uniqueSongs = new Dictionary<string, AnalyzedSong>(); using (var mediaLib = new XnaMediaLibrary()) { foreach (XnaSong s in mediaLib.Songs) { string id = string.Concat(s.Artist.Name, s.Name) .Replace(" ", ""); uniqueSongs[id] = new AnalyzedSong { ItemId = id, ArtistName = s.Artist.Name, SongName = s.Name }; } SongsOnDevice.AddRange(uniqueSongs.Values .OrderBy(s => s.ArtistName) .ThenBy(s => s.SongName)); } SongsOnDeviceLoaded = true; logger.Info("Completed GetSongsOnDevice"); }
public static void GetSongsOnDevice(object state) { App thisApp = App.Current as App; List<AnalyzedSong> songs = thisApp.Model.SongsOnDevice; Dictionary<string, AnalyzedSong> uniqueSongs = new Dictionary<string, AnalyzedSong>(); lock (songs) { using (var mediaLib = new XnaMediaLibrary()) { foreach(XnaSong s in mediaLib.Songs) { string id = string.Concat(s.Artist.Name, s.Name) .Replace(" ", ""); uniqueSongs[id] = new AnalyzedSong { ItemId = id, ArtistName = s.Artist.Name, SongName = s.Name }; } songs.AddRange(uniqueSongs.Values .OrderBy(s => s.ArtistName) .ThenBy(s => s.SongName)); } thisApp.Model.SongsOnDeviceLoaded = true; } }