Ben Voigt (the author) gives an excellent example on how to use the inherent BaseStream member of SerialPort which is more efficient for using the underlying Win32 API.Port = new SerialPort("COM" + PORT_NUMBER.ToString()); ...private void ReadEvent() { byte[] buffer = new byte[2000]; Action kickoffRead = null; kickoffRead = (Action)(() => Port.BaseStream.BeginRead(buffer, 0, buffer.Length, delegate(IAsyncResult ar) { try { int count = Port.BaseStream.EndRead(ar); byte[] dst = new byte[count]; Buffer.BlockCopy(buffer, 0, dst, 0, count); RaiseAppSerialDataEvent(dst); } catch (Exception exception) { MessageBox.Show(ERROR == > " + exception.ToString()); } kickoffRead(); }, null)); kickoffRead(); }问候. 这篇关于C#中最快的串口通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-26 16:13