15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


OpenFile CATCH

Jeff Oakes -- ets!jeff@uu7.psi.com
Tuesday, January 30, 1996

I've got a class that uses the OpenFile() function.
I need a way to get an exception if for instance the device on COMx is
suddenly turned off.  Right now, my application just locks up.

Any suggestions?

Thanks!

 - jeff@ets.com
------------------------------------------------
http://www.iquest.net/~jeff
------------------------------------------------




Mike Blaszczak -- mikeblas@interserv.com
Wednesday, January 31, 1996

On Tue, 30 Jan 96, Jeff Oakes  wrote:
>I've got a class that uses the OpenFile() function.
>I need a way to get an exception if for instance the device on COMx is
>suddenly turned off.  Right now, my application just locks up.
>
>Any suggestions?

Create a separate thread and use the WaitCommEvent() API with flags like 
EV_CTS and/or EV_DSR. Depending on the hardware, maybe you'd also wait on 
EV_RLSD or EV_BREAK.

Have that extra thread pitch another event or message which your main thread 
(or your I/O thread) can see.  Have your main thread or your I/O thread use 
WaitMessage() or use a CSingleLock with a zero time out to find the other 
event.  That way, the waiting won't get in your way.

.B ekiM
--
TCHAR szMusic[] = _T("This note is my own; I don't play for the Seattle 
Symphony Orchestra.");





| Вернуться в корень Архива |