public void Process(SocketAsyncEventArgs args)
{
if (args.SocketError == SocketError.Success)
{
if (args.BytesTransferred == 0)
{
// remote socket was closed
_completionWaitHandle.Set();
return;
}
_processReceivedBytesAction(args.Buffer, args.Offset, args.BytesTransferred);
ResumeOperation(args);
return;
}
if (IsErrorResumable(args.SocketError))
{
ThreadAbstraction.Sleep(30);
ResumeOperation(args);
return;
}
if (args.SocketError != SocketError.OperationAborted)
{
Exception = new SocketException((int) args.SocketError);
}
// we're dealing with a (fatal) error
_completionWaitHandle.Set();
}