Consider the following scenario:
A data packet is sent out of a serial port and a return packet is expected a
short time later.
The application sending the packet needs to send another packet as soon as
the return packet has been received. It needs to wait for the return packet,
but time out if one is not received.
Whilst packets are being exchanged the application needs to be responsive.
To maximise throughput, should the packets be sent on a separate thread? How
would the application wait for the thread to complete (without blocking) in
order to send subsequent packets? Looping with DoEvents causes CPU % to
shoot up, and Sleep(x) introduces excessive delays between packets.
TIA
Charles 20 2011
Charles,
Dependent on the method (an RS232 control, API-calls, ...) you use to
communicate with RS232, you might make use of an event or a callback
whenever return-data comes in.
Regards,
jan
"Charles Law" <bl***@nowhere. com> wrote in message
news:e6******** ********@TK2MSF TNGP12.phx.gbl. .. Consider the following scenario:
A data packet is sent out of a serial port and a return packet is expected
a short time later.
The application sending the packet needs to send another packet as soon as the return packet has been received. It needs to wait for the return
packet, but time out if one is not received.
Whilst packets are being exchanged the application needs to be responsive.
To maximise throughput, should the packets be sent on a separate thread?
How would the application wait for the thread to complete (without blocking)
in order to send subsequent packets? Looping with DoEvents causes CPU % to shoot up, and Sleep(x) introduces excessive delays between packets.
TIA
Charles
Hi Charles,
I do it by just let the subthread raise an public event and set a handler
for that in the program that starts the thread.
What do I mis?
Cor Consider the following scenario:
A data packet is sent out of a serial port and a return packet is expected
a short time later.
The application sending the packet needs to send another packet as soon as the return packet has been received. It needs to wait for the return
packet, but time out if one is not received.
Whilst packets are being exchanged the application needs to be responsive.
To maximise throughput, should the packets be sent on a separate thread?
How would the application wait for the thread to complete (without blocking)
in order to send subsequent packets? Looping with DoEvents causes CPU % to shoot up, and Sleep(x) introduces excessive delays between packets.
TIA
Charles
Hi Jan
I have an event that is raised when data is received, and I do my packet
detection there. This event is already on a separate thread, so once a
complete packet has been received I just set a flag to indicate the arrival.
My main send and receive thread needs to wait for this flag, but I don't
want to use excessive cpu time effectively polling the flag until it is set.
That is why I wondered about a wait on another thread, or something like
that.
Charles
"Jan" <ms****@tss.b e> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Charles,
Dependent on the method (an RS232 control, API-calls, ...) you use to communicate with RS232, you might make use of an event or a callback whenever return-data comes in.
Regards, jan
"Charles Law" <bl***@nowhere. com> wrote in message news:e6******** ********@TK2MSF TNGP12.phx.gbl. .. Consider the following scenario:
A data packet is sent out of a serial port and a return packet is
expected a short time later.
The application sending the packet needs to send another packet as soon
as the return packet has been received. It needs to wait for the return packet, but time out if one is not received.
Whilst packets are being exchanged the application needs to be
responsive. To maximise throughput, should the packets be sent on a separate thread? How would the application wait for the thread to complete (without blocking) in order to send subsequent packets? Looping with DoEvents causes CPU % to shoot up, and Sleep(x) introduces excessive delays between packets.
TIA
Charles
Hi Cor
The reason I haven't done this is because the main thread needs to wait for
the return packet before sending the next packet out.
At some point, it seems to me, there has to be a wait in order to keep the
packets transferring synchronously.
I had thought of doing it something like this:
Application thread
------------------
Do
Wait for send thread to terminate
Start send thread to send packet
Loop
Send thread
------------
Send packet
Wait for return packet to be received; timeout if none received.
Terminate thread
but I cannot work out how to do this without wasting time polling the send
thread and blocking the application thread.
Charles
"Cor" <no*@non.com> wrote in message
news:ex******** ******@TK2MSFTN GP12.phx.gbl... Hi Charles,
I do it by just let the subthread raise an public event and set a handler for that in the program that starts the thread.
What do I mis?
Cor
Consider the following scenario:
A data packet is sent out of a serial port and a return packet is
expected a short time later.
The application sending the packet needs to send another packet as soon
as the return packet has been received. It needs to wait for the return packet, but time out if one is not received.
Whilst packets are being exchanged the application needs to be
responsive. To maximise throughput, should the packets be sent on a separate thread? How would the application wait for the thread to complete (without blocking) in order to send subsequent packets? Looping with DoEvents causes CPU % to shoot up, and Sleep(x) introduces excessive delays between packets.
TIA
Charles
Hi Charles,
That is what I had in a program, but now it is just as beneath, I deleted a
lot and changed the Dutch a little bit to English
So it is just for the idea what I am doing, I hope I did not cut to much it
are more classes you know.
Cor
\\\
Application thread
Private WithEvents SendThread As New clsSendThread
Protected Sub threadReady() Handles SendThread.thre adReady
do some things,
Sendthread.main ()
End Sub
/// clsSendthread
Public Event threadReady()
main Sub
ThreadAThread = New System.Threadin g.Thread(Addres sOf ThreadA)
ThreadAThread.S tart()
end sub
Private Sub ThreadA()
Dim myfunction As New TheFunction()
doReady(myfunct ion.doyourthing s)
End Sub
Private Sub doReady(ByVal errors As String)
do some things
RaiseEvent threadKlaar()
End Sub
///
Charles,
In case the required processing is not too extensive, you might just do it
in that event, instead of only setting a flag.
Regards,
Jan
"Charles Law" <bl***@nowhere. com> wrote in message
news:u9******** ******@TK2MSFTN GP10.phx.gbl... Hi Jan
I have an event that is raised when data is received, and I do my packet detection there. This event is already on a separate thread, so once a complete packet has been received I just set a flag to indicate the
arrival. My main send and receive thread needs to wait for this flag, but I don't want to use excessive cpu time effectively polling the flag until it is
set. That is why I wondered about a wait on another thread, or something like that.
Charles
"Jan" <ms****@tss.b e> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Charles,
Dependent on the method (an RS232 control, API-calls, ...) you use to communicate with RS232, you might make use of an event or a callback whenever return-data comes in.
Regards, jan
"Charles Law" <bl***@nowhere. com> wrote in message news:e6******** ********@TK2MSF TNGP12.phx.gbl. .. Consider the following scenario:
A data packet is sent out of a serial port and a return packet is expected a short time later.
The application sending the packet needs to send another packet as
soon as the return packet has been received. It needs to wait for the return packet, but time out if one is not received.
Whilst packets are being exchanged the application needs to be responsive. To maximise throughput, should the packets be sent on a separate
thread? How would the application wait for the thread to complete (without
blocking) in order to send subsequent packets? Looping with DoEvents causes CPU %
to shoot up, and Sleep(x) introduces excessive delays between packets.
TIA
Charles
Jan
The processing required is actually to send the next packet, and then wait
for a return packet. If I do this in the event I'm in danger of entering a
recursive spiral, as the event will be raised for the return packet,
whereupon I send out the next packet and wait for the return, and continue
to go deeper and deeper.
Charles
"Jan" <ms****@tss.b e> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Charles,
In case the required processing is not too extensive, you might just do it in that event, instead of only setting a flag.
Regards, Jan
"Charles Law" <bl***@nowhere. com> wrote in message news:u9******** ******@TK2MSFTN GP10.phx.gbl... Hi Jan
I have an event that is raised when data is received, and I do my packet detection there. This event is already on a separate thread, so once a complete packet has been received I just set a flag to indicate the arrival. My main send and receive thread needs to wait for this flag, but I don't want to use excessive cpu time effectively polling the flag until it is set. That is why I wondered about a wait on another thread, or something like that.
Charles
"Jan" <ms****@tss.b e> wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Charles,
Dependent on the method (an RS232 control, API-calls, ...) you use to communicate with RS232, you might make use of an event or a callback whenever return-data comes in.
Regards, jan
"Charles Law" <bl***@nowhere. com> wrote in message news:e6******** ********@TK2MSF TNGP12.phx.gbl. .. > Consider the following scenario: > > A data packet is sent out of a serial port and a return packet is expected a > short time later. > > The application sending the packet needs to send another packet as soon as > the return packet has been received. It needs to wait for the return packet, > but time out if one is not received. > > Whilst packets are being exchanged the application needs to be responsive. > > To maximise throughput, should the packets be sent on a separate thread? How > would the application wait for the thread to complete (without blocking) in > order to send subsequent packets? Looping with DoEvents causes CPU % to > shoot up, and Sleep(x) introduces excessive delays between packets. > > TIA > > Charles > >
Hi Cor
I'm not sure I understand what happens here, but it looks like I would need
a wait in there somewhere whilst the return packet comes in. Otherwise, the
process would just run through and terminate and the next packet could get
sent out before the previous return packet had been received. Have I
misunderstood?
Charles
"Cor" <no*@non.com> wrote in message
news:et******** ******@TK2MSFTN GP10.phx.gbl... Hi Charles,
That is what I had in a program, but now it is just as beneath, I deleted
a lot and changed the Dutch a little bit to English
So it is just for the idea what I am doing, I hope I did not cut to much
it are more classes you know.
Cor \\\ Application thread Private WithEvents SendThread As New clsSendThread Protected Sub threadReady() Handles SendThread.thre adReady do some things, Sendthread.main () End Sub /// clsSendthread Public Event threadReady() main Sub ThreadAThread = New System.Threadin g.Thread(Addres sOf ThreadA) ThreadAThread.S tart() end sub Private Sub ThreadA() Dim myfunction As New TheFunction() doReady(myfunct ion.doyourthing s) End Sub Private Sub doReady(ByVal errors As String) do some things RaiseEvent threadKlaar() End Sub ///
Hi Charles,
It are three classes.
The main class
A starter stopper class
A class that does the things in a thread (You do not see that , only the
declaration of it)
for me it looks very much as your problem.
Have a look for it, I have also something with a timer, but that is not what
you want I think.
Cor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Charles Law |
last post by:
Hi guys. I'm back on the threading gig again.
It's the age-old question about waiting for something to happen without
wasting time doing it.
Take two threads: the main thread and a worker thread. The worker thread is
reading the serial port, waiting for something to happen (a service
request). When it does it raises an event. Of course, the event is executed
on the worker thread. The idea is that when the event is raised, the handler...
|
by: Mark |
last post by:
Is there a way to achieve multithreading in JavaScript? I'm looking to
fetch a page into a div while allowing the user to interact with another
div. At some point the newly fetched page contents will be available to the
div that the user is working in but I don't want to cause unnecessary
blocking. I've thought of using frames (would prefer divs) plus timeouts
and checking for when a load completes. Does anyone have an idea of how
this...
|
by: Johnsy Joseph |
last post by:
Hello Everybody,
I am trying to write a program that reads a single character, but I
always need to press the enter key too. Is there any way to read just
a single character without waiting for the enter key to also be
pressed?
Thanks for the help and time.
Warm Regards
|
by: Zachary Burns |
last post by:
I've been banging my head over this for a few hours and I'm not finding any
good code samples to demonstrate MultiThreading in C# Framework 1.1 that
shows me how to basically have the UI code stay separate from the Threading
code but allow a return parameter to the UI.
I'd like to have something like the following pseudocode....Is this even
possible?
main.cs
{
|
by: Jurgen |
last post by:
Hello,
I've a C# program that:
1) loads data for 30000 items from SQL Server
2) loops through all the items and does some extensive calculaltions on the data
3) loops through all the items to Writs the resutls back to the DB
This takes about half an hour, almost equally divided between step 2 and step1+3. The program runs
on the same machine as the SQL Server.
So I have 1 CPU intensive step and 2 disc I/O intensive steps.
I've never...
| |
by: Manuel |
last post by:
I have a long function that needs to be done 1000 times. I'm
multithreading it, but I don't want to load them up all at once, instead
load them 10 at a time.
So far the only way I can get it to work is by creating a dummy form
with a timer. On the timer function I test if the number of threads are
less than 10 then run the remaining ones. This is working fine, but I
would like to know how to do it without the form.
This is the code...
|
by: Bruce Wood |
last post by:
Maybe it's just late in my day, but I'm reading Jon's article on
threading, in particular how to use Monitor.Wait() and Monitor.Pulse(),
and there's something that's not sinking in. The code in question
looks like this:
public class ProducerConsumer
{
readonly object listLock = new object();
Queue queue = new Queue();
|
by: denis.cornehl |
last post by:
Hi,
I have an unusual Problem with DB2.
It is DB2 Version 7 and Fixpack 13 under Windows.
We have written an application server which is accessing db2 via c++
and the cli interface.
We used IBM Visual Age as our compiler, because we had to support OS/2.
Now we ported it this year to windows and the microsoft-compiler (V8).
|
by: Lars Uffmann |
last post by:
In an event routine, I want to end a certain thread. I am setting a flag
that is checked by the thread and causes it to end, when it is set. Then
the thread sets a "response" flag, just before exiting. In the event
routine, I would like to wait for that response flag, because at that
point, I can be sure that the old thread (even if it still is alive
between setting the response flag and exiting) will no longer interfere
with a subsequent...
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |