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();
-
- 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;
- }
I have Noticed by following breakpoints That the debugger is hanging when it goes to execute PageParse Method