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
Omnissiah
Omnissiah6mo ago
this is a garbage collected language, this stuff is usually done for you; what are you specifically worried about
Angius
Angius6mo ago
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 scope
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server