Delegates for Setting Control Properties

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to set a property of a control from a thread started from the UI
thread using Delegates. I can set the property directly in the thread if I
set the form's CheckForIllegalCrossThreadCalls property to False. However, I
don't want to do that so I am trying to use Delegates and the control's
invoke method.

Any suggestions on how to do this?
 
hello Dennis

this should work

### simple example

Delegate Sub CrossThreadInvParaMC()

Public Sub Test()
If YourcontrolName.InvokeRequired Then
Dim d As New CrossThreadInvParaMC(AddressOf Test)
Me.Invoke(d, Nothing)
Else
'do whatever you want to do e.g.

YourcontrolName.Propname='blahblah'


End If
End Sub
######





this works fine here ( asynchronous delegates and seperate threads that
comunicate to 1 gui to to show whats happening to the user
 
Worked great...thanks.
--
Dennis in Houston


Michel Posseth said:
hello Dennis

this should work

### simple example

Delegate Sub CrossThreadInvParaMC()

Public Sub Test()
If YourcontrolName.InvokeRequired Then
Dim d As New CrossThreadInvParaMC(AddressOf Test)
Me.Invoke(d, Nothing)
Else
'do whatever you want to do e.g.

YourcontrolName.Propname='blahblah'


End If
End Sub
######





this works fine here ( asynchronous delegates and seperate threads that
comunicate to 1 gui to to show whats happening to the user
 
Back
Top