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