/// <summary> /// Generates the text received event. /// </summary> /// <param name="e">Event arguments that contains received text.</param> protected virtual void OnTextReceived(TextReceivedEventArgs e) { if (this.TextReceived != null) { this.TextReceived(this, e); } }
/// <summary> /// The event handler to process received data through COM-port or UDP communication. /// </summary> /// <param name="sender">Sender object.</param> /// <param name="e">Event arguments that contains received text.</param> private void OnTextReceived(object sender, TextReceivedEventArgs e) { if (this.InvokeRequired) { // Using this.Invoke causes deadlock when closing serial port, and BeginInvoke is good practice anyway. this.BeginInvoke(new EventHandler<TextReceivedEventArgs>(this.OnTextReceived), new object[] { sender, e }); return; } this.historyBox.AppendTextReceivedFromRobot(e.Text); }