跨线程调用form控件技巧
private delegate void MethodSocket(object obj);//使用托管
ss = "OK"; this.BeginInvoke(new MethodSocket(InvokerReadMsg), ss);//this指向本窗口,回调函数InvokerReadMsg, private void InvokerReadMsg(object obj)//在这个函数里面能够直接訪问Form控件txtContent { this.txtContent.Text += obj.ToString() + "\r\n"; }
byte[]与string型相互转换 //byte 转stringstring test = Encoding.Default.GetString(bytes, 0, length);//string 转 byte byte[] bytes = System.Text.Encoding.Default.GetBytes(test);