T
Tom L
I'm using a listener that is using threads (for a messaging type app).. The
listener is declared on my form.. then in my little socket server class,
I've got..
Do
SyncLock tThread
If ServerOn = True Then
ProcessServer()
End If
If ClientOn = True Then
ProcessClient()
End If
tThread.Sleep(SweepTime)
End SyncLock
Loop
When ProcesServer is called, it triggers off the dataarrival event. For
testing purposes, I had it outputing in a mgbox, which worked fine.
But then I want to take the data and send it back to the form, when I do
that I get an error:
The action being performed on this control is being called from the wrong
thread. You must marshal to the correct thread using "Control.Invoke or
Control.BeginInvoke to perform this action."
stack trace:
at System.Windows.Forms.TreeNode.Realize()
at System.Windows.Forms.TreeNodeCollection.Add(TreeNode node)
at isrMessaging.frmCommunicator.Server_DataArrival(String Data, Thread thrd)
As you can tell, I'm trying to dump the response into a treeview node
Can anyone offer some help on how I get this to work? As you can tell, I'm
very new to threads..
Thanks
listener is declared on my form.. then in my little socket server class,
I've got..
Do
SyncLock tThread
If ServerOn = True Then
ProcessServer()
End If
If ClientOn = True Then
ProcessClient()
End If
tThread.Sleep(SweepTime)
End SyncLock
Loop
When ProcesServer is called, it triggers off the dataarrival event. For
testing purposes, I had it outputing in a mgbox, which worked fine.
But then I want to take the data and send it back to the form, when I do
that I get an error:
The action being performed on this control is being called from the wrong
thread. You must marshal to the correct thread using "Control.Invoke or
Control.BeginInvoke to perform this action."
stack trace:
at System.Windows.Forms.TreeNode.Realize()
at System.Windows.Forms.TreeNodeCollection.Add(TreeNode node)
at isrMessaging.frmCommunicator.Server_DataArrival(String Data, Thread thrd)
As you can tell, I'm trying to dump the response into a treeview node
Can anyone offer some help on how I get this to work? As you can tell, I'm
very new to threads..
Thanks