private void SetRichText(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.richTextRxMessage.InvokeRequired) { SetRichTextCallback d = new SetRichTextCallback(SetRichText); this.Invoke(d, new object[] { text }); } else { this.richTextRxMessage.AppendText(text); } }
public void AppendText(RichTextBox rtb, string value) { if (InvokeRequired) { try { SetRichTextCallback d = new SetRichTextCallback(AppendText); this.Invoke(d, new object[] { rtb, value }); //this.Invoke(new Action<string>(AppendTextBox), new object[] { value }); } catch { } return; } else { rtb.AppendText(value + Environment.NewLine); } }