/// <summary> /// Constructor attaches the shutdown event handlers immediately /// </summary> static ShutdownEventCatcher() { #if (!NETCOREAPP2_0) kernel32Handler = new Kernel32ShutdownHandler(Kernel32_ProcessShuttingDown); SetConsoleCtrlHandler(kernel32Handler, true); #endif AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; }
private static extern bool SetConsoleCtrlHandler(Kernel32ShutdownHandler handler, bool add);