protected virtual void OnDataReceived(BashDataReceivedEventArgs e) { _logStringBuilder.Append($"{e.TimeReceived:u} : {e.BashData}"); EventHandler<BashDataReceivedEventArgs> handler = DataReceived; handler?.Invoke(this, e); }
private void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { SerialPort serialPort = sender as SerialPort; var serialData = serialPort?.ReadExisting(); _commandOutputStringBuilder.Append(serialData); BashDataReceivedEventArgs args = new BashDataReceivedEventArgs { BashData = serialData, TimeReceived = DateTime.Now }; OnDataReceived(args); }
private void PollTcpStream() { while (PollLog) { var tcpData = ReadTcpStream(); if (!string.IsNullOrEmpty(tcpData)) { _commandOutputStringBuilder.Append(tcpData); BashDataReceivedEventArgs args = new BashDataReceivedEventArgs { BashData = tcpData, TimeReceived = DateTime.Now }; OnDataReceived(args); Thread.Sleep(100); } } }