private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { this.Invoke((MethodInvoker)delegate { try { ListWithURLs = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPlayList"); SearchEngine engine = new SearchEngine(textBox1.Text); engine.Search(); listBox2.Items.Add(engine.GetFiles()); axWindowsMediaPlayer1.currentPlaylist = ListWithURLs; axWindowsMediaPlayer1.Ctlcontrols.stop(); } catch { } }); }
private void LoadSearcResult() { Thread.Sleep(TimeSpan.FromSeconds(2)); this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate () { SearchEngine engine = new SearchEngine(TextBoxSearch.Text); engine.Search(); _Result = engine.GetFiles(); _ResultUrls = engine.GetUrls(); ListWithURLs = activeXMediaPlayer.playlistCollection.newPlaylist("vkPlayList"); for (int i = 0; i < _ResultUrls.Count(); i++) { URL = activeXMediaPlayer.newMedia(_ResultUrls[i]); ListWithURLs.appendItem(URL); } activeXMediaPlayer.currentPlaylist = ListWithURLs; activeXMediaPlayer.Ctlcontrols.stop(); ListBoxSearch.ItemsSource = engine.GetFiles(); } ); }