When I started using .NET I made the assumption that any UI element that required 'Invoking' from a thread would implement the InvokeRequired property. However this is not true and there are some lightweight UI elements such as Toolstrip items and TreeView nodes which are not derived from the Control class but still should only be updated from the UI thread.
So what should be done if there is no Invoke method? Well the answer is to use the Invoke/InvokeRequired of
any control present on the host form, even the form itself.
private delegate void LabelUpdateDelegate(String text);
private void UpdateStatusLabel(String text) {
if (this.InvokeRequired) {
this.Invoke(new LabelUpdateDelegate(UpdateStatusLabel), text);
} else {
status.Text = text;
}
}
Alan.