需要建议更好的解决方案,多线程,基于计时器的解决方案之间的选择...... [英] Need advice for better solution, selection between multi threading, timer based solution or anything else...
本文介绍了需要建议更好的解决方案,多线程,基于计时器的解决方案之间的选择......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个设备在90毫秒后发送数据(基于Windows的解决方案),基于数据,经过一些操作后,我必须同时向tcp上的其他20个客户端发送数据。什么是更好的解决方案。可以基于计时器的解决方需要帮助。
我尝试过:
我试过多线程,但造成100%的CPU使用率,thread.sleep()函数也产生问题,bcoz有时tcp客户端也需要时间来响应。
I have a device that is sending data after 90 mili seconds(windows based solution) , on the basis of data, after some operations, I have to send data to 20 other clients on tcp Simultaneously. What can be the better solution. Can timer based solution work? Need help.
What I have tried:
I have tried multithreading, but causing 100 percent CPU usage, thread.sleep() Function is also creating problem, bcoz sometimes tcp clients also takes time to respond.
推荐答案
每90毫秒?这就是为什么你的CPU负载是100%。
查看.Net中的TPL内容
任务并行库(TPL)| Microsoft Docs [ ^ ]
Every 90 milliseconds? THAT is why your CPU load is 100%.
Check out the TPL stuff in .Net
Task Parallel Library (TPL) | Microsoft Docs[^]
这篇关于需要建议更好的解决方案,多线程,基于计时器的解决方案之间的选择......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文