Hi babylon,
As long as the control has been created from UI thread different from the
one changing the property the execution has to be switch to the UI thread
created the control. You can use your control's Invoke method
Example:
Yo need to insolate setting Selected property in separate method. Say the
method has the following prototype
void SetSelected(int index); //this is one possible prototype. you could
have more complex one.
1. decalre and delegate for this prototype
delegate void SetSelectedIndexHandler(int index);
2. Declare the SetSelected method as follows
void SetSelectedIndex(int index)
{
//ctrl is a reference to the control, which selected property you want
to set
if(ctrl.InvokeRequired)
{
ctrl.Invoke(new SetSelectedIndexHandler(SetSelected), new
object[]{index});
}
//Set the control's Selected property here.
ctrl.SelectedIndex = index
}
In this example thread safety is guaranteed by setting the selected property
from the UI thread only.
--
HTH
B\rgds
100
babylon said:
I know how to 'invoke' a method......but now...
I have a control that has a property "Selected"
I would like to change it from different thread...
how can I invoke it?
thx