public override int EndRead(IAsyncResult asyncResult) { AsyncResultRead ar = asyncResult as AsyncResultRead; int bytesRead = ar.EndRead(); _asyncResultRead = null; return(bytesRead); }
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { if (_asyncResultRead != null) { throw new Exception("Only one outstanding read supported"); } _asyncResultRead = new AsyncResultRead(this, buffer, offset, count, callback, state); return(_asyncResultRead); }