コード例 #1
0
        private void PreloadAlbumsThread()
        {
            var dispatcher = System.Windows.Deployment.Current.Dispatcher;

            dispatcher.BeginInvoke(new Action(() =>
            {
                IsLoadingList = true;
                if (BusyStateChanged != null)
                {
                    BusyStateChanged(this, new EventArgs());
                }
            }));

            _albumsCache = null;
            if (_selectedArtist != null)
            {
                _albumsCache = new ObservableCollection <AlbumEx>();
                foreach (var album in _selectedArtist.Albums)
                {
                    var albumEx = new AlbumEx();
                    albumEx.Base = album;
                    if (albumEx.Base.Songs.Count > 0)
                    {
                        _albumsCache.Add(albumEx);
                    }
                }
            }
            if (AlbumsLoaded != null)
            {
                dispatcher.BeginInvoke(new Action(() =>
                {
                    IsLoadingList = false;

                    if (BusyStateChanged != null)
                    {
                        BusyStateChanged(this, new EventArgs());
                    }

                    if (AlbumsLoaded != null)
                    {
                        AlbumsLoaded(this, new EventArgs());
                    }
                    OnChange("Albums");
                }));
            }
            var thread = Thread.CurrentThread;

            lock (_activeThreadsLock)
            {
                if (_activeThreads.Contains(thread))
                {
                    _activeThreads.Remove(thread);
                }
            }
        }
コード例 #2
0
        private void PreloadAlbumsThread()
        {
            var dispatcher = System.Windows.Deployment.Current.Dispatcher;

            dispatcher.BeginInvoke(new Action(() =>
            {
                IsLoadingList = true;
                if (BusyStateChanged != null)
                    BusyStateChanged(this, new EventArgs());
            }));

            _albumsCache = null;
            if (_selectedArtist != null)
            {
                _albumsCache = new ObservableCollection<AlbumEx>();
                foreach (var album in _selectedArtist.Albums)
                {
                    var albumEx = new AlbumEx();
                    albumEx.Base = album;
                    if (albumEx.Base.Songs.Count > 0)
                    {
                        _albumsCache.Add(albumEx);
                    }
                }
            }
            if (AlbumsLoaded != null)
            {
                dispatcher.BeginInvoke(new Action(() =>
                {

                    IsLoadingList = false;

                    if (BusyStateChanged != null)
                        BusyStateChanged(this, new EventArgs());

                    if (AlbumsLoaded != null)
                        AlbumsLoaded(this, new EventArgs());
                    OnChange("Albums");
                }));
            }
            var thread = Thread.CurrentThread;
            lock (_activeThreadsLock)
            {
                if (_activeThreads.Contains(thread))
                    _activeThreads.Remove(thread);
            }
        }