[DllImport("kernel32.dll")]
static extern bool SetConsoleCtrlHandler(ControlEventHandler e, bool add);
I use this to catch and manage console interrupts, specifically Ctrl. + C
.
It works well under Windows 7 with .NET,
however I want to port this to mono
on arch-linux
.
When running it (regardless if built on Windows or directly on the linux machine with xbuild) I get
System.EntryPointNotFoundException: SetCtrlHandler
at (wrapper managed-to-native) rzs_slim.consoleControl:SetConsoleCtrlHandler (rzs_slim.ControlEventHandler, bool) //rzs_slim is the project, consoleControl the class
at [ctor of consoleControl]
at [Main]
How can I use this call to native code in mono? Can I reference the .dll in mono?
EDIT:
Actually, since this is a console-application I was able to achive the desired effect by subscribing my cleanup-function to the Console.CancelKeyPress
-Event