C# Console Application: Preventing Control-C from being printed?
Posted
by Alan
on Stack Overflow
See other posts from Stack Overflow
or by Alan
Published on 2010-06-16T22:28:52Z
Indexed on
2010/06/16
22:32 UTC
Read the original article
Hit count: 278
Hi.
I have a console app, and I want to capture Control-C and shutdown gracefully.
I have the following code:
Console.CancelKeyPress += new ConsoleCancelEventHandler((o, e) =>
{
Logger.Log("Control+C hit. Shutting down.");
resetEvent.Set();
});
And the output windows shows:
6/16/2010 3:24:34 PM: Control+C hit. Shutting down.
^C
Is there a way to prevent the control-c character ^C
from appearing? It's not a huge deal, but for some reason Ill be fixated on it because I'm anal like that.
© Stack Overflow or respective owner