Esempio n. 1
0
 // Install the control handler.
 private static void SetupControlHandler()
 {
     HandlerRoutine = new ConsoleCtrlHandlerDelegate(ControlHandler);
     if (!WinCon.SetConsoleCtrlHandler(HandlerRoutine, true))
     {
         throw new IOException("Unable to set handler routine.", Marshal.GetLastWin32Error());
     }
 }
Esempio n. 2
0
 // Uninstall the control handler.
 private static void ReleaseControlHandler()
 {
     if (HandlerRoutine != null)
     {
         if (!WinCon.SetConsoleCtrlHandler(HandlerRoutine, false))
         {
             throw new IOException("Unable to clear handler routine.", Marshal.GetLastWin32Error());
         }
         HandlerRoutine = null;
     }
 }