Hi Alex
I'll come clean. I fibbed. I am updating a control, but I use Invoke for
that. What I actually have is a user control (UserControl1) that combines a
progress bar and a track bar. The track bar is used to set a value for the
progress bar, and when this happens the control raises an event to say that
it has happened.
This user control is placed on another user control (UserControl2), which
has a property 'Position'. This parent user control is then placed on a
form. The form also has a Position property.
The worker (background) thread can change the position as well, by
Form1.Position = 50
The form level Position property contains
UserControl2.Position = Value
The UserControl2 Position property contains
UserControl1.Position = Value
Finally, the UserControl1 Position property has
If ProgressBar1.InvokeRequired Then
' Use delegate and Invoke to set value
Else
' Set property directly
End If
As you will see, I have only used Invoke at the final stage, even though, if
I test UserControl2.InvokeRequired for example, at the higher level, I find
that it is True.
Does this mean that I should have, at the form level
If UserControl2.InvokeRequired Then
' Use delegate and Invoke to set value
Else
' Set property directly
UserControl1.Position = Value
End If
or am I ok with what I have?
Charles