I've noticed that if I try to use the Application.Exit
instruction inside a constructor sub it does not take any effect, so what should be the proper way to end the execution of the application in this circunstances?
I know that I could just use the application events to cancel the startup
event, or wait for the Load
or Shown
event to properly exit the application calling the Application.Exit
method, but I'm asking this for learn the proper way to do it in a constructor sub without using the End
statement, in case that could be possibly.
This is an example:
Public Class Form1: Inherits Form
''' <summary>
''' Initializes a new instance of the <see cref="Form1"/> class.
''' </summary>
Public Sub New()
Application.Exit
' End
End Class
Environment.Exit(0) will do the trick.