0

Hi all ,

i'm writing a program that communicates with com port.
i need to send a few packets.

the thing is that i want to wait after each packet so that the receiver could send me an ack !

in pseud code :

for (x=0;x<Packets.Lenth;x++)
{
    sendData(Packets[x]);
    
   waitForDataReceivedEvent ();
}

my question is how do i implement waitForDataReceivedEvent ?

a serialport class event is raised - its called SerialDataReceivedEventHandler. how can i make my original method (the one with the for loop) to wait until this event is raised ?

thanks
Zvika

Edited by zismad: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by zismad
0

Use the AutoResetEvent class, and call WaitOne() where you want to wait for the packet.

Then you need to write a SerialDataReceivedEventHandler function, and in there call the Set() method on the same AutoResetEvent instance that you are waiting on.

Edited by ZootAllures: clarify wording

0

had already found it at msdn sorry for not marking it as solved ...
anyway it works great !


Zvika

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.