2

I would like my console launch a function when it closing, like that :

Sub Console_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

But, I'm not using Windows Form but the module, and I can't import Windows Form in the project. Haven't you got an idea ? Tanks ;)

  • https://stackoverflow.com/q/1119841/1271037 https://stackoverflow.com/q/4646827/1271037 https://stackoverflow.com/q/11291352/1271037 – dovid Aug 10 '17 at 00:35

1 Answers1

1

Use ProcessExit event of the AppDomain.

Sub Main
   AddHandler AppDomain.CurrentDomain.ProcessExit, AddressOf OnClose
End Sub

Sub OnClose(sender as object, e as EventArgs)
   'codeon close
End Sub
dovid
  • 6,354
  • 3
  • 33
  • 73
  • Tank you ! But, when I click on the close button, sub doesn't run. I will use links, tanks :) –  Aug 10 '17 at 00:49