473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Call Multithreaded Sub from Timer

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
Dec 4 '06 #1
3 1637
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

<msnews.microsoft.comschreef in bericht
news:uN**************@TK2MSFTNGP02.phx.gbl...
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


Dec 5 '06 #2

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.

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:OQ**************@TK2MSFTNGP03.phx.gbl...
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

<msnews.microsoft.comschreef in bericht
news:uN**************@TK2MSFTNGP02.phx.gbl...
>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



Dec 5 '06 #3
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

<msnews.microsoft.comwrote in message
news:uN**************@TK2MSFTNGP02.phx.gbl...
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


Dec 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Vedran Furac | last post by:
How can I call a function every time a specified number of milliseconds elapses? Javascript has setInterval() function and I need something like that. Currently I use this: def function(): t =...
2
by: pradyumna | last post by:
In Project settins - C/C++ - Code Generation, what is the difference between the option "Multithreaded" and "Multithreaded DLL". I understand that on selecting multithreaded option, single and...
6
by: Dan Kelley | last post by:
We have a multithreaded app that responds to events, and writes these events to a text file. This text file is used by an external system for further processing. We want to be able to write...
1
by: ravinder | last post by:
I wanted to develop a multithreaded program using OO concepts on windows platform. Problem: I have to simulate two layers(similar to TCP/IP stack layers), and the layer functionality is of finite...
9
by: wdwedw | last post by:
I have included all the source codes in the attached MyTest.zip (http://www.codeguru.com/forum/attachment.php?attachmentid=11218) There are three projects: VBTestCOM project is a apartment...
3
by: Borr | last post by:
Hi, I have an ASP .NET page, that runs client side timer that does something on the Server side and after that loads another page. So I have on client side something like : function...
4
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, Does the System.Windows.Forms.Timer invoke the main form thread? Or does it start another thread so that I need to lock my objects on which it operates in case the user of the program saves...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.