Either:
1) Add a handler to the
SerialPort.DataReceived Event (System.IO.Ports) | Microsoft Learn[
^] and read it in there.
But ... remember two things:
a) The event fires each time there is data in the port - that doesn't mean "a line of data" - it will fire each time a character arrives. So you can't just assign the data to a sting each time you read it as you will discard all previous characters, probably before your user gets a chance to see them.
b) The event does not fire on the UI thread - so you cannot directly access any controls like TextBoxes: you would need to Invoke them.
Or:
2) Set up a BackgroundWorker thread to read the data, and pass it up to the UI thread via teh progress reporting mechanism for it to display.