public void SetComponentText(object control, string message) { if (this.InvokeRequired) { SetComponentTextCallback componentCB = new SetComponentTextCallback(SetComponentText); this.Invoke(componentCB, new object[] { control, message }); } else { // cast the control dynamic ctrl = (dynamic)control; // Update the specified control. ctrl.Text = message; } }