I have just started a project to control an industrial instrument that communicates via RS-232 serial port. Baud rate is limited to 9600...fairly slow.
This instrument can operate in two modes - polled, where the PC sends a request, and the instrument replies with the data; or continuous, where the instrument sends a constant stream data. The data needs to be converted from ASCII to floating point numbers, and plotted.
My initial experiments with sample programs that use the SerialPort DataRecieved event were not auspicious...it was very easy to get the user interface to become non-responsive under continuous transmission from the instrument.
I've looked at other sample projects that spawn separate tasks, etc, but they all seemed quite complicated, and I'm wondering if there is a better way, especially with the capabilities of the newest .NET runtimes (4.5.1 as I write this).
Things like the Async API, and Dataflow look especially promising for this type of application. I've started experimenting with the Async API for receiving data. Code is very simple, but am having some issues with making it robust (exception handling).
Simplest approach seems to be to use async methods to parse the data into some kind of thread safe queue, which raises events to the UI for plotting. But I'm still working out the details.
Looking for suggestions on the best way to approach this.