private static void CallbackReceive(IAsyncResult ar) { //throw new NotImplementedException(); alldone.Set(); Informations.MyInfo info_ = (Informations.MyInfo)ar.AsyncState; int length = 0; try { length = info_.socket.EndReceive(ar); } catch (Exception) { throw; } if (length > 0) { info_.Text = "<<<接受信息成功>>>" + Encoding.UTF8.GetString(info_.Data); Array.Clear(info_.Data, 0, info_.Data.Length); Messages.SendMessage(info_.Handle, Messages.Wm_Receive_Info, 0, ref info_); } }
public static extern int SendMessage( IntPtr hWnd, //消息发生串口句柄 int msg, //消息号 int wParam, //参数1 ref Informations.MyInfo IParam //参数2 );