void _resolveWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker obj = (BackgroundWorker)sender;

            while (!obj.CancellationPending)
            {
                try
                {
                    if (IsConnected)
                    {
                        //可以接收
                        if (BufferStream.Buffer.Count > 0)
                        {
                            IMessageEntity msg = MessageDataAdapterObject.Resolve();
                            if (msg != null)
                            {
                                OnMessageReceived(new MessageReceivedEventArgs(msg));
                            }
                        }
                        else
                        {
                            Thread.Sleep(5);
                        }
                    }
                    else
                    {
                        Thread.Sleep(5);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.ToString(), ex);
                }
            }
        }
 void SerialPortObject_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     try
     {
         if (IsConnected)
         {
             //可以接收
             QueueObject qo = new QueueObject();
             qo.Buffer     = new byte[SerialPortObject.BytesToRead];
             qo.DataLength = SerialPortObject.Read(qo.Buffer, 0, qo.Buffer.Length);
             if (qo.DataLength > 0 && qo.Buffer.Length >= 1)
             {
                 BufferStream.AddRangeWithLock(qo.Buffer);
                 IMessageEntity msg = MessageDataAdapterObject.Resolve();
                 if (msg != null)
                 {
                     OnMessageReceived(new MessageReceivedEventArgs(msg));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex.ToString(), ex);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SerialPortLib.MessageReceivedEventArgs"/> class.
 /// </summary>
 /// <param name="data">Data.</param>
 public MessageReceivedEventArgs(IMessageEntity data)
 {
     Data = data;
 }