Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multithreaded dialer

Status
Not open for further replies.

lilboi

Programmer
Dec 22, 2003
146
CA
Hello all!

I know how VB has a single thread architecture, but could still kinda do a lil' bit of multi-threaded stuff.

My situation here is, I wrote a vb program that takes messages from the MSMQ, parses it then dials it out through the modem. The thing is, the modem is really slow. So instead of 1 modem, we'll be adding 1 or more modems.

I know how to check which modems are free (open or close), but how will I branch the program off so that it will send it to the modem that is free and continue taking messages off the queue.

pick up message from queue
if modem 1 is free, dial through modem 1.
pick up message from queue
since modem 1 is not free, check modem 2.
if modem 2 is free, send through modem 2.

Thanks guys!
 
1) Break your code to two programs:
- one that takes messages from the MSMQ, parses it (i.e. parser.exe)
- and one that dials out through the modem (i.e. dialer.exe)
- each one is a separate .exe

2) The parser can “parse the data" (and possibly save in a database or a file) then, it should check if there is a modem ready. It should then call the dialer.
3)The dialer.exe is configured to look at the database (or file) and get the next available record and work on it; once done dialing out, it should either delete the record or put a flag on it that it is done(i.e. done=True), then it terminates itself

Hope this help
 
thanks for the reply!

so the paser will call the dialer. Once the dialer is called, it dials into the free modem, then closes itself when done?

Should I do a dialer1.exe and dialer2.exe if there are modem 1 and 2?

Instead of going thru the database, what do you think 'bout calling and passing parameters to it?
ex. dialer1.exe <number> <message>

thanks
 
Yes, the parser will call the dialer and the dialer will dial out and terminate itself (i.e. use the End statement at the end of your code). You don't have to use a db, I thought it might be a good idea if you want to keep track of the process (i.e. when was each message created, sent, success, etc.).
I’m not sure if you need to create two separate exe’s. I think (but you have to test it with two small programs) that if you called an exe twice, it’ll basically create a new instance of the same .exe file and it will run in its own memory space. You can then pass your parameters when you run it (since you’re not using a db).

Also, I think the parser should control (and pass through to the dialer) which modem is free because the parser must first make sure that there is a free modem before it can call a new instance of the dialer anyway.

Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top