Hi,
I'm using a delegate to edit some controls on formA from another thread on
formB.
This works nicely the first time I run formA. But if I close formA and
reopen it I get errors.
When changing the checked state of a radiobutton I get an error saying that
I cannot access the control since it is disposed. But I can still change the
text in a textbox without errors. The textboxes doesn't seem disposed to the
other thread, but the radiobuttons do.
Why this strange behaviour?
I'd be really thankfull for any help on this.
Best regards
Daniel
ps. below are the parts of my code that edit the controls. ds.
'these lines are in the other thread
Dim del As Measure.MyDelegate
del = New Measure.MyDelegate(AddressOf Measure.updateValues)
Dim xh As Object = Me.Handle
Me.BeginInvoke(del, currentValues) 'currentValues is an array of Objects
'in the declarations of Measure
Public Delegate Sub MyDelegate( ... ByVal value8 As Boolean, ByVal value9 As
String, ... )
Private Shared Event currentValuesChanged()
Private Shared rbnIn1Checked As Boolean = False
Private Shared txtSpeedText As String = ""
'in the OnLoad sub
AddHandler currentValuesChanged, AddressOf HandlerCurrentValuesChanged
'the sub that is executed using the delegate
Public Shared Sub updateValues( ... ByVal value8 As Boolean, ByVal value9 as
String, ... )
'...
rbnIn1Checked = value8
txtSpeedtext = value9
'...
RaiseEvent currentValuesChanged()
End Sub
'the handler of the event
Private Sub HandlerCurrentValuesChanged()
'...
Me.rbnIn1.Checked = rbnIn1Checked 'this line raises an error
Me.txtSpeed.text = txtSpeedtext 'this doesn't
'...
End Sub