Rs232 control

  • Thread starter Thread starter Lou
  • Start date Start date
L

Lou

I am using the rs232 control and when I get the datareceived and try to
assign it
to a textbox I get some sort of thread message error

-Lou
 
I am using the rs232 control and when I get the datareceived and try to
assign it
to a textbox I get some sort of thread message error


You need to marshal the call back to the GUI thread using
'control.begininvoke"
 
Do you have an example?


Private Delegate Sub UpdateControlDelegate(ByVal Text as string)

Private Sub UpdateControl(Byval Text as String)
If MyControl.InvokeRequired Then
MyControl.BeginInvoke(New UpdateControlDelegate(AddressOf
UpdateControl), new object(){Text})
Else
... Do Update Here
End If
End Sub


P.S. you don't need to create the delegate if you're not passing in
parameters - in which case you can just use the built in MethodInvoker
delegate.
 
AWESOME!

Spam Catcher said:
Private Delegate Sub UpdateControlDelegate(ByVal Text as string)

Private Sub UpdateControl(Byval Text as String)
If MyControl.InvokeRequired Then
MyControl.BeginInvoke(New UpdateControlDelegate(AddressOf
UpdateControl), new object(){Text})
Else
... Do Update Here
End If
End Sub


P.S. you don't need to create the delegate if you're not passing in
parameters - in which case you can just use the built in MethodInvoker
delegate.
 
Back
Top