delegate void AddTextToDisplayDelegate(String Cont);// gọi phương thức bất kì đâu private void AddTextToChatDisplay(String Cont) { if (this.InvokeRequired)//cho biết có yêu cầu Invoke ko { AddTextToDisplayDelegate d = new AddTextToDisplayDelegate(AddTextToChatDisplay); this.Invoke(d, Cont);//chỉ cho phép thread được truy cập } else { txtChatDisplay.AppendText(Cont + Environment.NewLine); } }
public void AddTextToDisplay(String Info) { if (this.InvokeRequired) { AddTextToDisplayDelegate d = new AddTextToDisplayDelegate(AddTextToDisplay); this.Invoke(d, Info); } else { this.txtDisplay.AppendText(Environment.NewLine + "#" + Info); } }
private void AddTextToChatDisplay(String Cont) { if (this.InvokeRequired) { AddTextToDisplayDelegate d = new AddTextToDisplayDelegate(AddTextToChatDisplay); this.Invoke(d, Cont); } else { txtChatDisplay.AppendText(Cont + Environment.NewLine); } }