How to call public sub of form running in worker thread from main thread
I need help calling a public sub on a form running on a worker thread from the main thread. I think I need to use a delegate, but I've no idea how to declare or call a delegate.
I've created a form with one simple sub...
Public Sub Set_Prompt(ByVal Use_Prompt As String)
Me.Prompt_La.Text = Use_Prompt
I create a worker thread which shows the form, and I can close the form from the main thread using this code...
Dim WaitMsg_Win As WaitMsg = Nothing
Dim Msg_Thread As Thread
Dim Thread_Running As Boolean = False
Dim Use_Msg As String
Private Sub Show_WaitMsg()
WaitMsg_Win = New WaitMsg
Public Sub Display_Wait_Message(ByVal Wait_Msg As String)
Use_Msg = Wait_Msg
If (Not Thread_Running) Then
Msg_Thread = New Thread(AddressOf Show_WaitMsg)
Msg_Thread.IsBackground = True
Msg_Thread.Priority = ThreadPriority.BelowNormal
Msg_Thread.Name = "WaitMsg Thread"
Thread_Running = True
Catch ex As Exception
' Need to call WaitMsg_Win.Set_Prompt(Use_Msg)
Public Sub End_Wait_Message()
If (Thread_Running) Then
WaitMsg_Win = Nothing
Thread_Running = False
Catch Err_Ex As Exception
Thanks in advance for all help and suggestions.
Last edited by PlausiblyDamp; 01-25-2006 at 04:41 PM.
Reason: Added [vb] tags for readability