public void AddText(string text) { /*=====================================================*/ /* If we're attempting to modify the control from a */ /* different thread from the one that created it, then */ /* we need to use Invoke to handle the modification. */ /*=====================================================*/ if (m_RouterTextBox.InvokeRequired) { Form parentForm = m_RouterTextBox.FindForm(); AddTextCallback d = new AddTextCallback(AddText); parentForm.Invoke(d, new object[] { text }); } /*===================================*/ /* Otherwise the thread that created */ /* it can process the modification. */ /*===================================*/ else { m_RouterTextBox.AppendText(text); } }
public void AddText(string text) { if (_routerTextBox.InvokeRequired) { Form parentForm = _routerTextBox.FindForm(); AddTextCallback d = new AddTextCallback(AddText); parentForm.Invoke(d, new object[] { text }); } else { _routerTextBox.AppendText(text); } }