public BeginInvokeOC<Station> GetStationList(GetBy parameter, string value) { if (CachedStations == null) { CachedStations = new BeginInvokeOC<Station>(Dispatcher.CurrentDispatcher); } else { CachedStations.Clear(); } String streamURL; switch (parameter) { case GetBy.Search: streamURL = String.Format(URL + SEARCH_CMD, value); break; case GetBy.Genre: streamURL = String.Format(URL + GENRE_CMD, value); break; case GetBy.Default: streamURL = String.Format(URL + DEFAULT_CMD); break; default: throw new ArgumentOutOfRangeException("parameter"); } if (_backgroundThread != null && _backgroundThread.IsAlive) { shutdownThread = true; while (_backgroundThread.IsAlive) { Thread.Sleep(5); } } shutdownThread = false; Stream _stream = FeedStream.GetStream(streamURL); XmlTextReader reader = new XmlTextReader(_stream); CachedStations.Clear(); _backgroundThread = new Thread(Start) {Priority = ThreadPriority.BelowNormal}; _backgroundThread.Start(reader); return CachedStations; }
public ShoutcastFeedService() { CachedStations = new BeginInvokeOC<Station>(Dispatcher.CurrentDispatcher); }