Exemplo n.º 1
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            HmeAsyncResult result    = (HmeAsyncResult)asyncResult;
            int            readCount = _innerStream.EndRead(result.AsyncResult);

            Array.Copy(_innerStream.ReadBuffer, 0, result.ReadBuffer, result.Offset, readCount);
            return(readCount);
        }
Exemplo n.º 2
0
        public IHmeAsyncResult BeginWrite(byte[] buffer, int offset, int count, IHmeAsyncCallback callback)
        {
            HmeAsyncResult result = new HmeAsyncResult();

            result.Callback    = callback;
            result.AsyncResult = _innerStream.BeginWrite(buffer, offset, count, AsyncCallbackWrapper, result);
            return(result);
        }
Exemplo n.º 3
0
        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            HmeAsyncResult result = new HmeAsyncResult();

            result.AsyncState  = state;
            result.AsyncResult = _innerStream.BeginWrite(buffer, offset, count, new HmeAsyncCallback(callback, result));
            return(result);
        }
Exemplo n.º 4
0
        public IHmeAsyncResult BeginRead(int count, IHmeAsyncCallback callback)
        {
            HmeAsyncResult result = new HmeAsyncResult();

            result.Callback = callback;
            EnsureBuffer(count);
            result.AsyncResult = _innerStream.BeginRead(_readBuffer, 0, count, AsyncCallbackWrapper, result);
            return(result);
        }
Exemplo n.º 5
0
        private void AsyncCallbackWrapper(IAsyncResult asyncResult)
        {
            HmeAsyncResult hmeAsyncResult = (HmeAsyncResult)asyncResult.AsyncState;

            // AsyncResult could be null if operation completes syncronously
            if (hmeAsyncResult.AsyncResult == null)
            {
                hmeAsyncResult.AsyncResult = asyncResult;
            }
            hmeAsyncResult.Callback.AsyncCallback(hmeAsyncResult);
        }
Exemplo n.º 6
0
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            HmeAsyncResult result = new HmeAsyncResult();

            result.AsyncState  = state;
            result.ReadBuffer  = buffer;
            result.Offset      = offset;
            result.Count       = count;
            result.AsyncResult = _innerStream.BeginRead(count, new HmeAsyncCallback(callback, result));
            return(result);
        }
Exemplo n.º 7
0
        public int EndRead(IHmeAsyncResult asyncResult)
        {
            HmeAsyncResult result = (HmeAsyncResult)asyncResult;

            return(_innerStream.EndRead(result.AsyncResult));
        }
Exemplo n.º 8
0
        public void EndWrite(IHmeAsyncResult asyncResult)
        {
            HmeAsyncResult result = (HmeAsyncResult)asyncResult;

            _innerStream.EndWrite(result.AsyncResult);
        }
Exemplo n.º 9
0
 public HmeAsyncCallback(AsyncCallback callback, HmeAsyncResult result)
 {
     _callback = callback;
     _result   = result;
 }