Hello all. I was using the following code to send data asynchronously but I noticed that using WaitOne in the AsyncWaitHandle that I get from asyncRes doesn't wait at all. I checked MSDN and it says I should use a ManualResetEvent.
...
var asyncRes = _socket.BeginSend(encodedFrame, 0, encodedFrame.Length, SocketFlags.None, sendCallback, _socket);
...
var success = asyncRes.AsyncWaitHandle.WaitOne(_timeout, true);
...
private void sendCallback(IAsyncResult ar)
{
_socket.EndSend(ar);
}
MSDN also says in IAsyncResult:
AsyncWaitHandle: Gets a WaitHandle that is used to wait for an asynchronous operation to complete.
So why can't I use it for that purpose?
Thank you.