Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How do I make my bot to work with multithreading?


  • Please log in to reply
5 replies to this topic

#1 codegirl

codegirl

    CC Regular

  • Member
  • PipPipPip
  • 36 posts

Posted 04 September 2012 - 01:55 AM

Hello
I had just finish a test bot that would login into my yahoo mail and then log out just to see if it work. Yes it work when using a webbrowser but could someone provide me with sample codes that I could use if I were to put this as multithreading using 5 of my yahoo email accounts? Do I need to create five webbrowsers for this?
  • 0

#2 kernelcoder

kernelcoder

    CC Devotee

  • Expert Member
  • PipPipPipPipPipPip
  • 990 posts
  • Location:Dhaka
  • Programming Language:C, Java, C++, C#, Visual Basic .NET
  • Learning:Objective-C, PHP, Python, Delphi/Object Pascal

Posted 04 September 2012 - 02:34 AM

Yes, you have to create 5 WebBrowser or (5 tab of WebBrowser?). But you can't access (update) WebBrowser from thread.

Another way is to use WebClient class. You can use it in threads. You can use 3'rd party libraries (e.g. Html Agility Pack) to parse the html elements from the retrieved HTML.
  • 0

#3 AceInfinity

AceInfinity

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 313 posts
  • Programming Language:C, C++, C#, Perl, Visual Basic .NET, Assembly, VBScript, Others

Posted 05 September 2012 - 09:12 PM

Yes, you have to create 5 WebBrowser or (5 tab of WebBrowser?). But you can't access (update) WebBrowser from thread.

Another way is to use WebClient class. You can use it in threads. You can use 3'rd party libraries (e.g. Html Agility Pack) to parse the html elements from the retrieved HTML.


He wouldn't be able to access 5 different Yahoo accounts at the same time with 5 different webbrowsers unless he changed the proxy for each one.

I wouldn't suggest a WebBrowser anyways, because WebRequest's provide an easier way to change the proxy, and are much more suitable for sending modified POST data for navigating and retrieving data.

I wouldn't recommend a WebClient either, because you don't have free reign over POST data and cookies like you would with an HTTPWebRequest in order to maintain a login session, and as well login with your credentials to these Yahoo accounts.

~Ace
  • 0

Microsoft MVP (2012) - .NET Programming | ®Crestron DMC-T Certified Programmer
Posted Image


#4 StayAwake

StayAwake

    CC Lurker

  • New Member
  • Pip
  • 3 posts
  • Programming Language:Visual Basic .NET
  • Learning:Java, Visual Basic .NET

Posted 05 November 2012 - 04:56 PM

The way I would do it is like this:
- put your credentials in 2d array like this:

**username1**username2**username3**username4**username5**
**password 1**password 2**password 3**password4** password5**

then loop your program(with logging out) 5 time each time using the next username and pass from the array.

I don't know if this might work, just my first idea when rading your problem =)
  • 0

#5 AceInfinity

AceInfinity

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 313 posts
  • Programming Language:C, C++, C#, Perl, Visual Basic .NET, Assembly, VBScript, Others

Posted 05 November 2012 - 07:06 PM

That's not a very good depiction of a 2D array... Do you mean where user and pass are in one sub dimension? or where all usernames are one, and the other are all the passwords? Why not a dictionary? Why store them as hardcoded values anyways?

A few questions I would ask firsthand.
  • 0

Microsoft MVP (2012) - .NET Programming | ®Crestron DMC-T Certified Programmer
Posted Image


#6 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 05 November 2012 - 10:18 PM

Yes, you have to create 5 WebBrowser or (5 tab of WebBrowser?). But you can't access (update) WebBrowser from thread.

Another way is to use WebClient class. You can use it in threads. You can use 3'rd party libraries (e.g. Html Agility Pack) to parse the html elements from the retrieved HTML.


if you are serious about threading, you need to pay attention to kernelcoder's second paragraph because webbrowser is not best friends with threading... not that you can't make a couple of them to work fine, but ... is not the best alternative
  • 0




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download