I have 2 forms in my application (Form1 and Form2, Form1 is the startup form). I am connecting to the database in a new thread (In the FormLoad event of Form1, please see the code below) . If the connection to database on line# 4 fails i show Form2 (Which is basically a DB settings Form) but the form is disposed when the thread completes . How can make Form2 stay on the screen. Please see the code below
Expand|Select|Wrap|Line Numbers
- Public Class Form1
- Private Sub connectDB()
- Try
- 'DB connection code goes here ...
- Catch ex As Exception
- Dim f As New Form2
- f.Show()
- End Try
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Dim t As New Threading.Thread(AddressOf connectDB)
- t.IsBackground = False
- t.Start()
- End Sub
- End Class