Q:

Listening for input on a console app in a separate thread

I am currently working on a c# project which has an event handler for Console.CancelKey EventHandler. The problem I am having is if the user presses Ctrl+C to stop the app the event doesn't get triggered as I think it is too busy doing other stuff to handle the event. If the app is quiet, i.e. not having to do much work the Ctrl+C is caught and it runs that event handler. 
I assume I need to listen for the event handler in a separate thread so that it be understood but how would I go about doing this.
Thanks for any help you can provide. 

A:

You might try setting Console.TreatControlCAsInput, which stops CTRL+C combination from even being processed at the OS-level.  The caveat being that if the user truly does want to stop the application, they will either have to use CTRL+BREAK, or you will have to manually force the application to close after running your event handler.

