Currently, I'm using something like this:
public class CtrlBreakClass {
static bool CtrlHandler( uint ctrltype ) {
// your Ctrl+C/Ctrl+Break logic here
return true;
}
protected delegate bool CtrlHandlerDelegate( uint ctrltype );
[DllImport("kernel32.dll")]
protected static extern bool SetConsoleCtrlHandler( CtrlHandlerDelegate
handler, bool add );
static int Main( string[] args ) {
SetConsoleCtrlHandler( new CtrlHandlerDelegate( CtrlHandler ), true );
// do something useful here :)
return 0;
}
}
However, I'm getting a page-fault on complex programs(multi-threading,
events and mutexes around). If anyone knows why, I'd really like to know.
Regards,
Pablo Castro
Lagash Systems S.A.
----- Original Message -----
From: "Karl Botts" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 13, 2002 11:34 PM
Subject: [ADVANCED-DOTNET] Control-C Interrupt Handling
> Does anybody know how to catch or otherwise handle a Control-C in a C#
> console app under .NET?
>
> You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.