Accessing multiple sites....Multi-threading or multi browsers?

Joined
Apr 13, 2011
Messages
19
Programming Experience
Beginner
I have a need to build an app that will access about 10 websites and pass data to them, etc.

I've read about something called multi-threading when searching Google. I've also seen people say that they use multiple browsers.

Which route is better to use? I figure if you have to do some sort of multi-threading that you would access a single browser?

Not sure which way I should approach this app.

Any ideas?

Thanks
 
One instance of WebBrowser control can only load one page at a time. You can use multiple WebBrowser controls in UI thread, though it is also possible to create hidden browser instances from separate threads.
 
WebBrowser is a Windows Forms control...running it in a separate thread is painful (I recently tried this with a WebBrowser subclass that would suppress prompts and had a lot of trouble getting it to instantiate and work correctly on the separate thread. Running from the UI thread worked fine). To save headaches later on, you probably want all the instances on the main thread.

WebBrowser loads pages asynchronously, so you should be able to call WebBrowser.Navigate() and handle the DocumentCompleted() event. Note that the WebBrowser must be Visible (but does not need to belong to a form) in order to raise the DocumentCompleted event (microsoft bug). You can handle the site updating from the DocumentCompleted event handler, but you will need to Invoke changes since the WebBrowser exists on a separate thread. This can get painful since we start bringing Delegates into the scenario and it doesn't sound like you want that level of complexity.

I don't know how your site is setup, but if you are trying to do this asynchronously, you might want to try HTTP POSTing the data to the page. To find out what data is POSTed, I've found Fiddler to be a useful tool. Then you can run in as many threads as you want.
For more information on this, google vb.net HttpWebRequest post
The BackgroundWorker is a relatively easy way to handle multiple threads, or you could create a Thread object and call its Start method. Again there are examples of this on google.
 
Back
Top