public void removeUser(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.richTextBoxMainAct.InvokeRequired) { AddTextRowCallback d = new AddTextRowCallback(removeUser); this.Invoke(d, new object[] { text }); } else if (this.listBoxMainUsers.Items.Contains(text)) { this.listBoxMainUsers.Items.Remove(text); } }
public void AddTextRow(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.richTextBoxMainAct.InvokeRequired) { AddTextRowCallback d = new AddTextRowCallback(AddTextRow); this.Invoke(d, new object[] { text }); } else { this.richTextBoxMainAct.AppendText("[" + DateTime.Now.ToString("HH:mm") + "] " + text + "\n"); } }