I am getting this error when I try to read a property from a custom panel control. The property returns the value of a textbox within the panel. How do I read the property that returns the value of the textbox control from another thread? Sample of my property code is below. I am not worried about the setter.
Here is the eaxct error message:
Cross-thread operation not valid: Control ” accessed from a thread other than the thread it was created on.
public string Header
{
get
{
return _HeaderComboBox.Text;
}
set
{
_HeaderComboBox.Text = value;
}
}
MSDN sample using BeginInvoke
This is how I would implement the sample based on the getter snippet you posted:
There are more elegant methods, however, this is a general example for you.