I have an application that uses remoting - the usual pattern - Client calls a proxy of a remote object - remote object fires events which are broadcast to the client using delegates and call back - client recieves the broadcast messages and it has to display it on a form.
The problem occurs in the last part. I use the thread safe method of calling the form rich text control.
Private
Sub ClientEventHandler(ByVal Msg As String) Handles RemoteEvent'I confirmed that Msg has the write value
SetText(Msg)
End SubPrivate
Sub SetText(ByVal [Text] As String)' InvokeRequired required compares the thread ID of the ' calling thread to the thread ID of the creating thread. ' If these threads are different, it returns true. If Me.RichTextBox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText) Me.Invoke(d, New Object() {[Text]}) Else
Me.RichTextBox1.AppendText([Text]) End If End Sub
Everything works fine until the execution of Me.Invoke(d, New Object() {[Text]}). The form hangs(the execution of this one statement takes forever) at this point.
Please let me know what the reason could be.

Make Thread-Safe Calls to Windows Forms Controls
computerbill
Alibong
Are you sure that
Me.RichTextBox1.AppendText([Text])
is not trying to be called instead
Bryce Beagley
Can you tell me how to simulate the same pattern in a class (non windows form)
To be more specific can you give me or point me to a place where I can get some code snippets - specifically the contents of the InvokeRequired method of the windows controls.
Thanks.
SpoonsJTD
ks06
ozhonetech
Peter,
Many thanks for your reply. Your suggestions worked.
Actually I was not very familiar with the multithreading and GUI. I just took the thread safe method right from MSDN.