Call Multithreaded Sub from Timer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to have just a multithreaded sub procedure? What I need is a
timer time_elapsed event (2 sec interval) send params to a sub that is
multithreaded. I have a COM component used to send messages,faxes, etc..
The COM com component is licensed for 6 ports. I have an app that need to
send messages/faxes very frequently (seconds) and to many, many people.
What I want to do is have a sub that has 6 threads to send thse messages
when a timer (2 sec interval) gets data (fax numbers, etc.) from a db then
calls that multithreaded sub. If a port in the sub/com component is in use
the multithreading will use the other remaining poers (5 in this case).
Any thoughts would be greatly appreciated. I know I've posted simillar
questions before, however, I think this new approach to accomplishing this
task is somewhat different. I'd appreciate the thoughts. Thanks a lot.

Jay
 
Hi,

You have asked this before, and everybody was curious why you needed the
multithreading operation.

Can you not first give an answer on that. The process you describe does not
need a multithreading operation because you use the same device to send
through. You will probably only slowing down your process because that
parallel delivery to a device of more data will bring the performance down.

Cor
 
As cor mentioned ...

plus ...

Is the COM component a third-party tool ... or did you write it?

Now, how does the COM object work???

Can you have multiple instants of the COM object?
Can you specify which port each instants uses?
How does the COM object work when delivering a message ... when a port is
business...

for example ...

you tell the COM to send a fax ...
COM prepares the fax
COM dials the fax number
COM waits for a response from the FAX number
COM starts sending the the fax
COM completes sending the fax ...
COM notifies caller FAX is sent ...

At anytime during this process does the COM return control to the calling
program?
Does the calling programming 'listen' to the COM object for status updates?
If the COM object does not release control back to the caller during the
process ... you need to implement a solution that utilizes all six ports.
If the COM object does release control back to the CALLING PROGRAM ... you
have another question to answer ... how does the COM object handle rapid
fire calls ... call 1 - send a fax (5 steps) ... after 1st step ... returns
to caller and continues processing steps 2 to 5 ... now caller instantly
calls back to the COM object to send another fax ... does the com object
have to wait until the first call is completed before it can start
processing the second call???


Here is a suggestion ....

1. Do not use a timer ...
2. Create 6 instances of the same COM object ...
3. Force each instances of the COM object to use a specific port.


....process....

Start your program ...

Dim COM1 as New COM
Dim COM2 as New COM
Dim COM3 as New COM
Dim COM4 as New COM
Dim COM5 as New COM
Dim COM6 as New COM

Dim dr as DataRow
Dim ds as DataSet
Dim dt as DataTable

Dim iComCounter as Integer
Dim bFlag as Boolean

....Initialize...
bFlag = GetFlagValueFromDatabase ...used to stop you endless loop...
iComCounter = 1

COM1.UsePortNumber(1)
COM2.UsePortNumber(2)
COM3.UsePortNumber(3)
....


Do While bFlag

<load your dataset with new message list>

dt = ds.Table("MessageTable")

For Each dr in dt.Rows

Select case iComCounter
Case 1
iComcounter = iComcounter + 1

MySendMessage(COM1,dr)

Case 2
iComcounter = iComcounter + 1

MySendMessage(COM2,dr)

Case 3
iComcounter = iComcounter + 1
MySendMessage(COM3,dr)

Case 4
iComcounter = iComcounter + 1
MySendMessage(COM4,dr)

Case 5
iComcounter = iComcounter + 1
MySendMessage(COM5,dr)

Case 6
iComcounter = 1
MySendMessage(COM6,dr)

End Select

Next

' Just keep looping ... continually hitting the database for new messages
.... do not rely on your timer event! What happens when sending the messages
takes longer than you timer interval? Do you get multiple instances of the
programing running...

Loop


----------------------------------------

Sub MySendMessage(aCOM, adr)

....logic to send you message

End Sub


this is a suggestion to investigate ... again, why do you need MULTIPLY
THREADS??? Is the COM object MULTITHREADED ... can it handle multiple calls
without having to finish the previous call ... does it determine the next
available port or do you have to tell it which port to send the message ???
These are critical inorder to help you!

Jeff.
 
I do this but I am using Dialogic cards to connect to multiple phone lines
(up to a couple of hundred per computer) and as a development tool I use
either vb6 or vb.net 2003 - not 2005, together with vbvoice from Pronexus.
Its expensive though and you may not want to change. By the way I have no
relation with Pronexus. Just been using their stuff for a long time.
I don't have to worry about threads its pretty well done automatically.

HTH
Bob
 
Back
Top