Hello, this is more of a “best-practise” question…
In my app I have a thread responsible for tcp communication. Now I have a two options… I can poll the socket using HasPendingConnection. This would allow me to quit whenever I like, but it of course result in a massive CPU usage. Or I can use WaitForPendingConnection, but in that case, I cannot quit instantly, but in the worst case, I need to wait the whole WaitTime. It would be nice if there was a WaitForPendingConnection which would take not just the interval, but also an event which you could use to signal (from a different thread) that the function should exit. There is no such mechanism at this point, right?
What I do at this point is to pass to WaitForPendingConnection an interval which is low enough to be acceptable, when I need to quit the app. Something like 50 ms.
Is there a better way? What is a common way to implement this kind of stuff.
Thanks