Re: loggin on console app exit

Peter Ritchie <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <LISTSERV%[email protected]>
On Mon, 28 Jan 2008 11:51:33 -0500, Per Bolmstedt
<[email protected]> wrote:

>On Mon, 28 Jan 2008 11:43:04 -0500, Peter Ritchie
><[email protected]> wrote:
>
>It also won't trap ^C, right? Since ^C is probably considered a legal way
to
>end the program by most users, this may pose a problem.

My dealings with ^C have shown that sometimes you get a ProcessExit event
and sometimes you don't--which may stem from the fact that sometimes ^C
abnormally terminates the app and sometimes it doesn't.

>
>Is there a way to trap ^C?

As you've found out you can use the Console.CancelKeyPress to detect ^C.
but, even when you subscribe to CancelKeyPress and don't change the the
application doesn't always abnormally terminate.  It seems to more
reliably just continue rather than exit; but that is probably dependant on
what the application is doing when you press ^C.

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.