public void showMsg(string msg) { { //在线程里以安全方式调用控件 if (receiveMsg.InvokeRequired) { dShowInfo _myinvoke = new dShowInfo(showMsg); receiveMsg.Invoke(_myinvoke, new object[] { msg }); } else { string s = msg; if (!string.IsNullOrEmpty(msg)) { s = string.Format("[{0}],{1}\r\n", DateTime.Now.ToString("hh:mm:ss"), msg); } else { s = "\r\n"; } //if (receiveMsg.Lines.Length > 200) //{ // receiveMsg.Clear(); //} receiveMsg.AppendText(s); receiveMsg.Select(receiveMsg.Text.Length, 0); receiveMsg.ScrollToCaret(); } } }
public void ShowInfo(string Info) { if (_label.InvokeRequired) { showInfo = new dShowInfo(ShowInfo); _label.Invoke(showInfo, new object[] { Info }); } else { _label.Text = Info; } }