I recently was dealing with this error: BeginInvokeStackflowError
I am using threading,and according to my research it is because within the threading .start() event
Your app can be started other than the default "MainForm" method provided by the VB Application Framework. This will use a Sub Main as the starting point allowing you to control what forms show and when, and what happens before that:
' IF your form is declared here, it will be
' available to everything. e.g.:
' Friend mainfrm As Form1
Public Sub Main()
' this must be done before any forms/controls are referenced
Application.EnableVisualStyles()
' the main form for the app
' just "mainfrm = New Form1" if declared above
Dim mainfrm As New Form1
' eye candy for the user
Dim splash As New SplashScreen1
splash.Show()
' your code here to do stuff.
' you can also invoke your procedures on the main form
' mainfrm.FirstTimeSetup()
' for demo purposes
System.Threading.Thread.Sleep(2500)
' close/hide the splash once you are done
splash.Close()
' see note
' start the app with the main form
Application.Run(mainfrm)
End Sub
If you declare the splash screen as Friend at the top, you can truly extend it until all the form's load event is complete and close it there/then.