Hey all,
Thanks for taking the time to read this.
I am having an issue where I am starting another thread which opens a form. Succinctly, it is an animated "Please wait.. processing" type of form. The issue is that I want to make this form a child form of the parent (main thread or main GUI) when I open it.
The issue is that I prefer to use frmProcessing.ShowDialog(frmMain) instead of just frmProcessing.Show, because of form disappearing issues. It, of course, gives me an error of illegal cross thread operation. My question is, how do I perform frmProcessing.ShowDialog(frmMain) to show from within another thread, that the newly opened form is actually a child of the main thread. Is there a better way for me to make a small processing form telling the user to be patient while background processes are working?
Thank you for any help you can give me. The code is below.
SQL.vb
frmMain.processingForm
Thanks for taking the time to read this.
I am having an issue where I am starting another thread which opens a form. Succinctly, it is an animated "Please wait.. processing" type of form. The issue is that I want to make this form a child form of the parent (main thread or main GUI) when I open it.
The issue is that I prefer to use frmProcessing.ShowDialog(frmMain) instead of just frmProcessing.Show, because of form disappearing issues. It, of course, gives me an error of illegal cross thread operation. My question is, how do I perform frmProcessing.ShowDialog(frmMain) to show from within another thread, that the newly opened form is actually a child of the main thread. Is there a better way for me to make a small processing form telling the user to be patient while background processes are working?
Thank you for any help you can give me. The code is below.
SQL.vb
VB.NET:
frmMain.processing = New Threading.Thread(AddressOf frmMain.processingForm)
Dim processingInfo(1) As String
processingInfo(0) = "Loading SQL instances..."
frmMain.processing.IsBackground = True
frmMain.processing.Start(processingInfo)
Do Stuff...
frmMain.processing.Abort
frmMain.processingForm
VB.NET:
Public Sub processingForm(ByVal processingInfo() As String)
If frmProcessing.Visible = False Then
frmProcessing.ShowDialog()
End If
frmProcessing.Label1.Text = processingInfo(0)
Do
frmProcessing.Refresh()
Application.DoEvents()
Loop
End Sub