Create Multiple Background workers with HttpWebRequest

simpleonline1234

Junior Member
Joined
Jan 26, 2010
Messages
170
Reaction score
13
Okay so I've dug around all day and found that using multiple "background workers" would do what I would need for my application.

How can I create 4 background workers and then feed the urls to the webrequest from a listbox?
Code:
Dim request As HttpWebRequest = HttpWebRequest.Create(URLGOESERE)                 
Dim response As HttpWebResponse                 
response = CType(request.GetResponse, HttpWebResponse)                 
Dim webstream As Stream = response.GetResponseStream                 
Dim streamreader As New StreamReader(webstream, Encoding.UTF8)                 
Dim html As String = streamreader.ReadToEnd                 
Messagebox.show(html.tostring)

I'm basically needing to have each webrequest access the listbox, grab a URL, process the webrequest and then go grab the next url on file.

I am trying to have that running 4x at a time until the sites are all looped through.

I've read a background worker is good vs. multi threading because it's easier to code.
 
What language is this? I don't mind researching something.. if I know what it is.
 
It 's VB.NET - Thread moved to the proper section btw :)
 
lol I thought this would be easy for someone whos created the "Ferrari version of Xrumer and Scrapebox"

It's just fun for me. I don't mind giving it away for free. I mean I have my own personal version of what looks like the ferrari version of Ultimate Demon/Xrumer/Scrapebox but those I won't release...not yet anyways.

The little apps are easy to slap together..it's the ones that require months of planning that are the hardest to code but the best reward when you can hit the GO button and watch everything come together like magic.
 
Did I say Ferrari version? Oopps...I mean't to say the Pinto version...haha...I will be the Ferrari version when I'm done with it..well...if I ever get down with it. haha
 
Well I am more of a C# guy but I'll try to help out as much as I can.

Instead of doing the threads handling yourself, why don't you work with a thread pool? I needed something similar around 6 months ago or so and that's how I handled it. You can queue as many tasks as you want, pass arguments, and they'd all get done. You would also limit the thread number.

The key to start them and have the application running without it freezing would be making one new thread from which things would run - so if you want to stop the execution you just kill that thread, since it's the main thread for the queue, it would terminate all threads. Since its started from a separate thread, it wouldnt kill the application. There are a few other ways of doing it but they're a bit more complicated.

Let me know if you need any more help.
 
Thanks accelerator_22. That's the idea I was hunting for.

Cool beans...that makes perfect sense. I believe I will toss the webrequest for the captcha into the thread pool and then create an event to kill the thread by toggling the dispose on the captcha submit button which also sends a webrequest POST for create the account...thanks for your help.
 
lol I thought this would be easy for someone whos created the "Ferrari version of Xrumer and Scrapebox"

I think I have it ready to wrap up into an EXE and then I hit a road block which turns into another road block.
 
its all good mate, I was only having a laugh .

forget the background workers and just use threads, Check out this post by smack

http://www.blackhatworld.com/blackh...6-mulitthreading-httprequest.html#post2147637

he provides easy to follow pseudo code on how to multithread a list of urls, its how I learnt to do it...... you wont be able to multi-thread a listbox either (i dont think anyway), read it into an arraylist or something first
 
Back
Top