1

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.

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...

Matt
  • 367
  • 1
  • 5
  • 20

2 Answers2

1

I would not use a background thread. Rather have a look at a Timer in System.Threading. This is exactly what it was made for. Very easy to use.

uriDium
  • 13,110
  • 20
  • 78
  • 138
  • If this is used in a GUI based application, you either have to create a new thread for network connections and do the work there (to avoid blocking the whole gui) or use async network calls. – Philip Daubmeier Apr 19 '10 at 10:57
0

What about using a Backgroundworker or a background Thread (What is the difference?) with an endless loop, in which you sleep for a certain time (e.g. 1 minute) and poll the data.

Community
  • 1
  • 1
Philip Daubmeier
  • 14,584
  • 5
  • 41
  • 77