Is there a way to force C# compiler, visual studio 2010, to call a method whenever the user closes the console ? I know that this can be done in windows forms by some sort of event handling or using dispose methods, but what about console, is there any similar way to be able to call a method when closing it ?
You don't need a special technique in most cases...just add the routine you were thinking to the end of the program; well you can write your program in such a manner. However, if you still need to handle it there is a Ctrl+C mechanism or what is called CancekKeyPress event triggered.
Check this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With