void QueueSend(EventArgsPackage e) { //处理要发送数据 SendEventArgs args = e.Args as SendEventArgs; try { if (args.Buffer != null) { this.portSender.Send(args.Buffer); } else if (!string.IsNullOrEmpty(args.Text)) { this.portSender.Send(args.Text); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } }
void QueueReceive(EventArgsPackage e) { //处理收到的数据,将数据转发到所有的监听对象 if (receiverListener.Values.Count <= 0) return; foreach (IDevice item in receiverListener.Values) { try { item.OnReceived(e.Sender, e.Args as ReceiveEventArgs); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } }