user5905796
user5905796

Reputation:

Event when the console is Closing vb.net

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 ;)

Upvotes: 2

Views: 1861

Answers (1)

dovid
dovid

Reputation: 6491

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

Upvotes: 1

Related Questions