简体   繁体   English

C#轮询TCP服务器

[英]C# Polling a TCP Server

Hey everyone - I am wondering if anyone could help me out - I need to poll a TCP server frequently with a request to receive some real-time data. 大家好-我想知道是否有人可以帮助我-我需要经常轮询TCP服务器以获取一些实时数据的请求。

I know I will need to create a thread in order to talk to the server but I am unsure as to how to make this poll frequently. 我知道我需要创建一个线程才能与服务器对话,但是我不确定如何频繁进行此轮询。

Any help would be appreciated... 任何帮助,将不胜感激...

I would not use a background thread. 我不会使用后台线程。 Rather have a look at a Timer in System.Threading. 而是看看System.Threading中的Timer。 This is exactly what it was made for. 这正是它的目的。 Very easy to use. 很好用。

使用无休止循环的Backgroundworker或后台线程(有什么区别? ),您将睡眠一段时间(例如1分钟)并轮询数据,该怎么办?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM