System.IO.Ports.SerialPort and Multithreading

后端 未结 4 681
清酒与你
清酒与你 2021-02-02 04:42

I have some SerialPort code that constantly needs to read data from a serial interface (for example COM1). But this seems to be very CPU intensive and if the user moves the wind

4条回答
  •  暖寄归人
    2021-02-02 05:06

    The classic solution is to have a FIFO buffer. Ensure that the size of the FIFO is large enough to handle any critical case where there is a lot of input and the processor block is being taken up.

    You could even have a 2-buffer system:

    --->|Reader|-->FIFO-->|Processor|--->FIFO2--->|Displayer|
    

提交回复
热议问题