ScrapySharp causes Windows Form to freeze without exception

785 Views Asked by At

When included in my code

ScrapingBrowser browser = new ScrapingBrowser();

WebPage testPage = browser.NavigateToPage(new Uri("https://www.google.co.uk/"));

causes the Windows Form to stop working (once this line is reached in execution, the form freezes and I have to halt execution). However, there are no errors or anything else to indicate something is wrong.

2

There are 2 best solutions below

0
nvoigt On

You should not use this method from your UI thread. Use your favorite technology (BackgroundWorker, Task, Thread) to run this on another thread that does not block the UI thread.

You could also use ScrapySharp's own async method: NavigateToPageAsync

1
Disu On

Seems that ScrappySharp doesn't work in Windows Forms. I've used the same Form code in a Console project and it works perfectly.