internal void Register() { Debug.Assert(!_handlerRegistered); bool r = Interop.Kernel32.SetConsoleCtrlHandler(_handler, true); if (!r) { throw Win32Marshal.GetExceptionForLastWin32Error(); } _handlerRegistered = true; }