private void OnDataArrived(ComService sender, DataArrivedArgs args) { if (DataArrived != null) { DataArrived(sender, args); } }
void ComService_DataArrived(object sender, DataArrivedArgs eArg) { DataArrivedArgs e = eArg; this.BeginInvoke(() => { try { _packetReceived.Text = e.PacketType + " (" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ")"; if (e.PacketType == PacketType.PollData) { string str = Encoding.ASCII.GetString(e.Data); str = str.Substring(1); // remove prefix var parts = str.Split('\t'); int rpms = int.Parse(parts[0]); _rpms.Text = rpms.ToString(); } } catch (Exception) { // todo: for some reason this will throw if connection is lost } }); }
private void OnDataArrived(ComService sender, DataArrivedArgs args) { if (DataArrived != null) { DataArrived(sender, args); } }