Exemple #1
0
        /// <summary>
        /// 监听sendMQ接收到的报文响应
        /// </summary>
        /// <param name="source"></param>
        /// <param name="asyncResult"></param>
        private void sendMqReceiveCompleted(object source, ReceiveCompletedEventArgs asyncResult)
        {
            MessageQueue mq = null;

            try
            {
                mq = source as MessageQueue;
                Message msg = mq.EndReceive(asyncResult.AsyncResult);
                if (msg.Body != null)
                {
                    Tuple <byte, byte[]> rs = DataConvert.DataToCan(msg.Body as byte[]);
                    Logger.Info(string.Format("CanInfo:帧ID:{0};内容:{1}", rs.Item1, BytesUtil.Bytes2HexString(rs.Item2)));
                    CANAPI.CanSend(rs.Item1, rs.Item2);
                }
            }
            catch (Exception exp)
            {
                Logger.Error("sendMqReceiveCompleted", exp);
            }
            try
            {
                if (mq != null)
                {
                    mq.BeginReceive();
                }
            }
            catch (Exception exp)
            {
                Logger.Error("sendMqReceiveCompleted", exp);
            }
            return;
        }