Click to See Complete Forum and Search --> : Multithread problem..


sats
July 17th, 1999, 02:15 AM
I'v developed a Comm-Port application. It is implemented using Multi threads. I'm starting a thread in which I'm calling WaitForMultipleObjects function(Read and Write are the events), after this I chick which event is signaled and Start thread,.. Write thread Or Read thread accordingly. Inside write thread I reset the event and do the write operation and return.
From the main thread I'm setting the Write event when i want to write to the port.
The problem here is..even though I set the write event only once, it is coming out of the WaitForMultipleObjects function due to write event twice. Due to this the write thread is getting started twice and two frames are been written to the port..What could be the problem..How do i solve this?

ThankX

July 19th, 1999, 06:56 PM
If you are using MFC and are using CEvent it comes in two flavors:Autoreset and Manual reset. In the former case the event goes to unsignalled state when a waiting function gets possession. In the later ResetEvent has to be explicitly called before that will happen.

sats
July 22nd, 1999, 01:30 AM
Here the CEvent is of manual reset type..and i'm resetting it thru code when i finish writing..and setting it ehen i want to write to commport..