Responding to CTRL_CLOSE_EVENT when the application is blocked
From: Krzysztof Zelechowski (krixel_at_WP.PL)
Date: 02/03/04
- Next message: George: "SetSystemCursor"
- Previous message: Gary Chanson: "Re: Telling between messages from userinterface and another application"
- Next in thread: Alex Blekhman: "Re: Responding to CTRL_CLOSE_EVENT when the application is blocked"
- Reply: Alex Blekhman: "Re: Responding to CTRL_CLOSE_EVENT when the application is blocked"
- Reply: Alexander Grigoriev: "Re: Responding to CTRL_CLOSE_EVENT when the application is blocked"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 3 Feb 2004 19:02:16 +0100
First let me give some background information to start with. If you attempt
to close the console of your character-mode application, the system presents
a dialog box saying that it cannot be cleanly closed. If you want to close
it in a more user-friendly way, you have handle a CTRL_CLOSE_EVENT the
system generates. You accomplish this by calling
SetConsoleCtrlHandler(ExitOnClose, TRUE);
where ExitOnClose is your handler. The handler gets called in a separate
thread so you can clean up and terminate the process.
My question is: can I choose to notify the other threads of my application
(the main thread, in my case)? It is easy if they have a chance to get that
notification by examining a shared variable. However, this does not work
for me because my application is reading input from the console at that
time. The only solution I have come up with is to close the standard input
handle within the handler. I would like to do it in a more elegant way.
What if it were reading from a local communications device? Performing an
asynchronous read is not a solution because the standard handles are open in
a synchronous mode and the standard cin object which I am using does not
support asynchronous operation. I would like to cause the read operation to
fail in order to unblock the main thread and test for notofication. It is
not possible with signals and exceptions because they all act upon the
current thread (unlike in Unix, where a blocking operation can be
interrupted from outside without killing the whole process altogether).
Any suggestions?
Chris
- Next message: George: "SetSystemCursor"
- Previous message: Gary Chanson: "Re: Telling between messages from userinterface and another application"
- Next in thread: Alex Blekhman: "Re: Responding to CTRL_CLOSE_EVENT when the application is blocked"
- Reply: Alex Blekhman: "Re: Responding to CTRL_CLOSE_EVENT when the application is blocked"
- Reply: Alexander Grigoriev: "Re: Responding to CTRL_CLOSE_EVENT when the application is blocked"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|