Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to navigate in a list of links using webbrowser?

I have a list of url and I need to navigate them. How can I make sure that every url will call the DocumentCompleted event ? I've already tried to create many threads and tried using a single thread too but the app is still not firing the event DocumentCompleted for each url.

Is there a way to make a loop in a list of urls and make them call a DocumentCompleted until the thread calls the next url ?

like image 212
galioni Avatar asked Feb 21 '14 13:02

galioni


1 Answers

To implement this, async/await and Task Parallel Library may come in handy. They allow to have familiar, pseudo-linear code flow for what is an asynchronous logic (handling DocumentCompleted events for multiple navigations, one after another).

I answered a similar question for a WinForm app here and for a console app here.

If you need to target .NET 4.0 but develop with VS2012+ , you still can use async/await, Microsoft provides the Microsoft.Bcl.Async library for that.

If C# 5.0 is not available for this project, you can use yield, as described here.

like image 181
noseratio Avatar answered Oct 29 '22 16:10

noseratio