public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { int left = this.Left; if (left <= 0) { var ar = new EmptyAsyncResult(); ar.AsyncState = state; ar.AsyncWaitHandle = new ManualResetEvent(true); callback(ar); return ar; } if (count > left) count = left; return base.BeginRead(buffer, offset, count, callback, state); }
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { int left = this.Left; if (left <= 0) { var ar = new EmptyAsyncResult(); ar.AsyncState = state; ar.AsyncWaitHandle = new ManualResetEvent(true); callback(ar); return(ar); } if (count > left) { count = left; } return(base.BeginRead(buffer, offset, count, callback, state)); }