Console Application On Exit (Win 11)
Is there a way to properly run code on exiting console app to release resources or just block the Ctrl+C and Closing the window exiting?
3 Replies
this is a garbage collected language, this stuff is usually done for you; what are you specifically worried about
You could try
PosixSignalRegistration.Create(PosixSignal.SIGINT, ctx => ...)
Or SIGTERM
That said, if there's anything that uses unmanaged resources, it should be IDisposable
or IAsyncDisposable
That way the resources get released automatically when they go out of scope
And the end of the Main()
method is one such scopeUnknown User•6mo ago
Message Not Public
Sign In & Join Server To View