C# BackgroundWorker and Com Port Problems

£可爱£侵袭症+ 提交于 2019-12-06 00:02:50

Create a single thread responsible for ALL send operations. Implement a Queue that feeds this thread with messages to send to the device. You can use the new BlockingCollection<T> to implement this easily.

OR, using TPL, create a TaskScheduler with a limited degree of parallelism of 1 as shown here:- http://msdn.microsoft.com/en-us/library/ee789351.aspx

Now you can simply fire of Tasks to send to the device and they will execute sequentially.

Unless there is some need to communicate information between the sender and the reader I would implement the reader operation on its own separate thread.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!