I am trying to parse an html page with HtmlAgilityPack to Extract links from it then add links to ListBox then add the links from listBox to queue.
I have three Tasks(PageParse,AddItemsToList,EnqueueFromList)
OK My problem is when I click the button the whole Application is hanging.
button Code
- private void CrawdBtn_Click(object sender, EventArgs e)
- {
- t = Task.Factory.StartNew(PageParse);
- t.Wait();
- TaskAddToList = Task.Factory.StartNew(() => AddItemsToList(t.Result));
- TaskAddToList.Wait();
- b = new Task(EnqueueFromList);
- b.Start();
- //Task.WaitAll(t,b);
- CrawdBtn.Enabled = true;
- }
Page Parse Method
- public HtmlAgilityPack.HtmlDocument PageParse()
- {
- MessageBox.Show($"Page Parse Has started");
- web = new HtmlWeb();
- doc = new HtmlAgilityPack.HtmlDocument();
- doc = web.Load(UrlText.Text);
- return doc;
- }
Replies
Know the answer? Post it — somebody with the same question will find it here.