vb.net - Module Based Application, Execute code OnExit? -
i have small vb.net application marked windows forms application however, there no forms.
everything driven module. done eliminate form of interface (form, console window, etc.). have new need execute bit of code prior application closing however, cannot seem find suitable event attach to.
whether app closes due unhandled exception (of course never happens..) or closed via task manager, need code execute. how can achieve this?
try subscribing application's exit event. in main (or whatever code called on application start), add handler:
addhandler application.applicationexit, addressof onapplicationexit
then define handler run when application shuts down.
'application exit hander private sub onapplicationexit(byval sender object, byval e eventargs) try ' ignore errors might occur while closing file handle. catch end try end sub
Comments
Post a Comment