I have a thread which sits around waiting for UDP messages from multiple interfaces using UdpClient::BeginReceive and a callback which calls UdpClient::EndReceive to pick up the data and pass it on.
If after 5 seconds I don't get anything, I return from the function which calls UdpClient::BeginReceive so that the process can be cancelled and to issue another broadcast which would trigger external clients to send in UDP responses. If we're not cancelling, I call the UdpClient::BeginReceive function again to check for new data.
If the client hasn't received any data in time, is there a way to cancel that async request without calling EndReceive which blocks indefinitely? I get the impression that leaving hundreds of async triggers running would be a bad idea.