G
Guest
I ran into a threading issue with vb.net 2005.
So I did some research and found out I could do one of two things.
I could use the following(Which I'm not a big fan of)
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf (ctl) Is TextBox Or TypeOf (ctl) Is Label Then
Control.CheckForIllegalCrossThreadCalls = False
End If
Next
or I have to use a delegate and call it like so
I like the secondary idea but I can't get my head around it. It's probably
simple and I've over complicated it but all I need to do is react to a raise
event call from a class on a form.
I have looked at all kinds of examples but I'm don't see how it applies to
my situation.
Does anyone have an example of what I need to do?
I just want to update labels and textboxes on my form when the event is
raised.
Here's the sub as it is now
Private sub mMachCtl_NotDecoded ()Handles mMachCtl.NoDecoded
txtColor.Text = "Error"
txtLotNum.Text = "Error"
Dim ctl as control
for each ctl in me.controls
if typeof ctl is label or typeof ctl is textbox then
ctl.backcolor = color.red
end if
loop
End Sub
so how do I setup the delegate, and something to make that happen?
So I did some research and found out I could do one of two things.
I could use the following(Which I'm not a big fan of)
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf (ctl) Is TextBox Or TypeOf (ctl) Is Label Then
Control.CheckForIllegalCrossThreadCalls = False
End If
Next
or I have to use a delegate and call it like so
I like the secondary idea but I can't get my head around it. It's probably
simple and I've over complicated it but all I need to do is react to a raise
event call from a class on a form.
I have looked at all kinds of examples but I'm don't see how it applies to
my situation.
Does anyone have an example of what I need to do?
I just want to update labels and textboxes on my form when the event is
raised.
Here's the sub as it is now
Private sub mMachCtl_NotDecoded ()Handles mMachCtl.NoDecoded
txtColor.Text = "Error"
txtLotNum.Text = "Error"
Dim ctl as control
for each ctl in me.controls
if typeof ctl is label or typeof ctl is textbox then
ctl.backcolor = color.red
end if
loop
End Sub
so how do I setup the delegate, and something to make that happen?