Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to cancel WaitCommEvent?

556 views
Skip to first unread message

erika knutsen

unread,
Dec 24, 2002, 11:47:11 AM12/24/02
to
hello,
we are building a program that reads COM port.
we use NON-overlapped (synchronous) IO.
we have a thread that calls WaitCommEvent(RX_CHAR)
and when character arrives, it reads it. but in some moment,
when user closes the program, we must get out of WaitCommEvent,
but we cant to it, because calling any Comm function
(inclusive CloseHandle(hPort)), blocks the application.
How is it possible to cancel non-overlapped WaitCommEvent
programmatically?

Thank you

Erika@mitcorp


Gary G. Little

unread,
Dec 24, 2002, 3:44:25 PM12/24/02
to
When you opened the the handle to the COM port did you set
FILE_FLAG_OVERLAPPED? This will permit asynchronous operation on that
handle.

--
Gary G. Little
Have Computer, Will Travel ...
909-698-3191
909-551-2105

"erika knutsen" <e...@mitcorp.tam.dk> wrote in message
news:aua32s$pr$1...@nsnmpen2-gest.nuria.telefonica-data.net...

arkadyf

unread,
Dec 25, 2002, 2:40:22 AM12/25/02
to
from MSDN description of SetCommMask :
dwEvtMask
[in] Specifies the events to be enabled. A value of zero disables all
events.
So simply call : SetCommMask ( h , 0 ) ;

Arkady

"erika knutsen" <e...@mitcorp.tam.dk> wrote in message
news:aua32s$pr$1...@nsnmpen2-gest.nuria.telefonica-data.net...

erika knutsen

unread,
Dec 26, 2002, 12:31:52 PM12/26/02
to
> from MSDN description of SetCommMask :
> dwEvtMask
> [in] Specifies the events to be enabled. A value of zero disables all
> events.
> So simply call : SetCommMask ( h , 0 ) ;
>

unfortunately.. it also blocks my program, because i am working in
SYNCHRONOUS (non-overlapped) mode.
so any call to any Comm function can be made when no other
function call is pending. and in my case, waitCommEvent waits
for signal that never arrives, and during this time, there seems
to be no way to cancel it..
the only way seems to be to rearrange the program to use overlapped
io, and to monitor events asynchronously

e.k@mitcorp


arkadyf

unread,
Dec 29, 2002, 3:40:13 AM12/29/02
to
You have to do it from different thread because this one blocked on wait.
Arkady

"erika knutsen" <e...@mitcorp.tam.dk> wrote in message

news:aufef8$9v3$1...@nsnmpen2-gest.nuria.telefonica-data.net...

0 new messages