I port to the .NET kernel, and the existing application hooked up the SetConsoleCtrlHandler win32 call to close the application so that it could completely close the open database files and other ordered shutdown tasks.
I need to do the same in the .NET kernel, and the only option I see is with ASP.NET, connecting to IApplicationLifetime ApplicationStopping.Register. However, this only captures Ctrl-C and does not work if the end user or system terminates the console application (for example, rebooting the system) that will be called by win32.
Another option is through AppDomain (AppDomain.CurrentDomain.ProcessExit), however AppDomain is not available in the dotnet core.
Orderly closing the application is important, and I'm concerned about data corruption in the production system, so you need to implement something equivalent, and the new application will run on Windows and Linux.
Did I miss a function in the dotnet core for this? Or do I need to re-implement windown shutdown and everything equivalent to Linux?
source share