public async Task <bool> GetListVideoOnChanel(string ChanelName, CancellationToken token) { if (token.IsCancellationRequested) { throw new OperationCanceledException(); } List <YoutubeVideo> listVideo; try { //----- get all list video on channel-----------// listVideo = await youtubeManager.GetListVideos(ChanelName, token); if (token.IsCancellationRequested) { throw new OperationCanceledException(); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { //-------remove video on list-----------// for (int i = VideoList.Count - 1; i >= 0; i--) { VideoList.RemoveAt(i); } //--- add list video-----// for (int i = 0; i < listVideo.Count; i++) { VideoList.Add(listVideo[i]); } } catch (Exception ex) { throw new OperationCanceledException(); } } ); } catch (Exception ex) { throw new OperationCanceledException(); } return(true); }
public void RemoveVideo(int ID) { bool vidFound = false; int index = -1; foreach (var video in VideoList) { if (video.id == ID) { index = VideoList.IndexOf(video); vidFound = true; break; } } if (vidFound) { VideoList.RemoveAt(index); } }