Delegates for Setting Control Properties

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?
 
M

Michel Posseth [MCP]

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top