private void btnDownloadFollowers_Click(object sender, RoutedEventArgs e) { SetUI(); Task.Factory.StartNew(() => { SoundCloud clsSound = new SoundCloud(); try { isDone = false; clsSound.lstUser = null; UpdateUI(); foreach (string users in listUsers.Items) { clsSound.lstUser.Add(users); } if (!clsSound.CountResults("followings")) { return; } clsSound.DownloadFollowers(); isDone = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { clsSound = null; EnableButtons(); } }); }
private void btnDownloadLikes_Click(object sender, RoutedEventArgs e) { SetUI(); Task.Factory.StartNew(() => { //Instantiate our class SoundCloud clsSound = new SoundCloud(); try { isDone = false; clsSound.lstUser = null; UpdateUI(); foreach (string users in listUsers.Items) { clsSound.lstUser.Add(users); } if(!clsSound.CountResults("favorites")) { return; } clsSound.DownloadLikes(); isDone = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { clsSound = null; Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { EnableButtons(); })); } }); }