private void btnGetChapter_Click(object sender, EventArgs e) { try { var titleUrl = new Uri(cbTitleUrl.Text); ITitle title = TitleFactory.CreateTitle(titleUrl); title.Proxy = Option.GetProxy(); btnGetChapter.Enabled = false; var task = title.PopulateChapterAsync(new Core.Progress <int>(progress => txtPercent.Text = progress + "%")); task.ContinueWith(t => { btnGetChapter.Enabled = true; dgvChapter.DataSource = title.Chapters; if (t.Exception != null && t.Exception.InnerException != null) { txtMessage.Text = t.Exception.InnerException.Message; } }, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void GetChapters(Uri seriesUri) { try { ITitle title = TitleFactory.CreateTitle(seriesUri); currentTitle = title; title.Proxy = Option.GetProxy(); btnGetChapter.Enabled = false; cbTitleUrl.Enabled = false; /// Remove focus from the title combo to avoid accidentally loading more /// series when scrolling. if (ActiveControl == cbTitleUrl) { ActiveControl = null; } var task = title.PopulateChapterAsync(new DMR11.Core.Progress <double>(progress => Animate(NetworkProgressBar, "ProgressValue", progress, 0, 1000))); task.ContinueWith(t => { cbTitleUrl.Enabled = true; btnGetChapter.Enabled = true; dgvChapter.DataSource = title.Chapters; dgvChapter.Focus(); PrepareSeriesDirectory(); if (t.Exception != null && t.Exception.InnerException != null) { txtMessage.Text = t.Exception.InnerException.Message; } }, TaskScheduler.FromCurrentSynchronizationContext()); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Information); } }