473,597 Members | 2,829 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1650
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.microso ft.comschreef in bericht
news:uN******** ******@TK2MSFTN GP02.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 = GetFlagValueFro mDatabase ...used to stop you endless loop...
iComCounter = 1

COM1.UsePortNum ber(1)
COM2.UsePortNum ber(2)
COM3.UsePortNum ber(3)
....
Do While bFlag

<load your dataset with new message list>

dt = ds.Table("Messa geTable")

For Each dr in dt.Rows

Select case iComCounter
Case 1
iComcounter = iComcounter + 1

MySendMessage(C OM1,dr)

Case 2
iComcounter = iComcounter + 1

MySendMessage(C OM2,dr)

Case 3
iComcounter = iComcounter + 1
MySendMessage(C OM3,dr)

Case 4
iComcounter = iComcounter + 1
MySendMessage(C OM4,dr)

Case 5
iComcounter = iComcounter + 1
MySendMessage(C OM5,dr)

Case 6
iComcounter = 1
MySendMessage(C OM6,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(a COM, 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******** ******@TK2MSFTN GP03.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.microso ft.comschreef in bericht
news:uN******** ******@TK2MSFTN GP02.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
accomplishin g 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.microso ft.comwrote in message
news:uN******** ******@TK2MSFTN GP02.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
5761
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 = threading.Timer(n, function) t.start() function()
2
6630
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 multithreaded applications can both use that dll, but what about multithreaded DLL option. Thanks
6
2781
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 multiple entries to the file, and then rename it and copy it to a new location when the file reaches a certian size, or a certain time span elapses (which ever comes first). I have created a static/shared timer member variable in class that writes...
1
1779
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 state machine type i.e after receiving any event(either after receiving message or any timer expiry), state change happens internal to layer. And there will be message transfer between two layers. My idea is to put layer specific data in the class and...
9
1577
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 threaded DLL, it has one function doing a stored procedure call. This DLL will be called from C++ multithread. C++ test project is a ATL multithreaded DLL, it just simple created multithread, and call VBTestCom's doSPCall function in each thread.
3
6927
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 OnPageLoad() { setTimeout("OnTimer()", 10000); }
4
1593
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 data while the Timer updates data. regards Jesper.
0
7967
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8272
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8031
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6687
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3882
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2403
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1233
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.