Exemple #1
0
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            //return inStream.BeginRead(buffer, offset, count, callback, state);

            //if (!this.CanRead)
            //{
            //   // __Error.ReadNotSupported();
            //}
            SynchronousAsyncResult ar = new SynchronousAsyncResult(state, false);
            try
            {
                //int num = Read(buffer, offset, count);
                int num = inStream.Read(buffer, offset, count);
                ar.m_NumRead = num;
                ar.m_IsCompleted = true;
                //ar._waitHandle.Set();
            }
            catch (IOException exception)
            {
                //ar._exception = exception;
            }
            if (callback != null)
            {
                callback(ar);
            }
            return ar;

        }
Exemple #2
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            //return inStream.EndRead(asyncResult);

            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            SynchronousAsyncResult result = asyncResult as SynchronousAsyncResult;

            if ((result == null) || result.IsWrite)
            {
                //__Error.WrongAsyncResult();
            }
            //if (result._EndXxxCalled)
            //{
            //    //__Error.EndReadCalledTwice();
            //}
            //result._EndXxxCalled = true;
            //if (result._exception != null)
            //{
            //    throw result._exception;
            //}
            return(result.m_NumRead);
        }
Exemple #3
0
        public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            //return inStream.BeginRead(buffer, offset, count, callback, state);

            //if (!this.CanRead)
            //{
            //   // __Error.ReadNotSupported();
            //}
            SynchronousAsyncResult ar = new SynchronousAsyncResult(state, false);

            try
            {
                //int num = Read(buffer, offset, count);
                int num = inStream.Read(buffer, offset, count);
                ar.m_NumRead     = num;
                ar.m_IsCompleted = true;
                //ar._waitHandle.Set();
            }
            catch (IOException exception)
            {
                //ar._exception = exception;
            }
            if (callback != null)
            {
                callback(ar);
            }
            return(ar);
        }
Exemple #4
0
        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {
            SynchronousAsyncResult ar = new SynchronousAsyncResult(state, true);

            try
            {
                //Write(buffer, offset, count);
                outStream.Write(buffer, offset, count);
                ar.m_IsCompleted = true;
                //ar._waitHandle.Set();
            }
            catch (IOException exception)
            {
                //ar._exception = exception;
            }
            if (callback != null)
            {
                callback(ar);
                //callback.BeginInvoke(ar, null, null);
            }
            return(ar);
        }
Exemple #5
0
        public override void EndWrite(IAsyncResult asyncResult)
        {
            //outStream.EndWrite(asyncResult);
            if (asyncResult == null)
            {
                throw new ArgumentNullException("asyncResult");
            }
            SynchronousAsyncResult result = asyncResult as SynchronousAsyncResult;

            if ((result == null) || !result.IsWrite)
            {
                //__Error.WrongAsyncResult();
            }
            //if (result._EndXxxCalled)
            //{
            //    //__Error.EndWriteCalledTwice();
            //}
            //result._EndXxxCalled = true;
            //if (result._exception != null)
            //{
            //    throw result._exception;
            //}
        }
Exemple #6
0
        public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
        {            
            SynchronousAsyncResult ar = new SynchronousAsyncResult(state, true);
            try
            {
                //Write(buffer, offset, count);
                outStream.Write(buffer, offset, count);
                ar.m_IsCompleted = true;
                //ar._waitHandle.Set();
           
            }
            catch (IOException exception)
            {
                //ar._exception = exception;
            }
            if (callback != null)
            {
                callback(ar);
                //callback.BeginInvoke(ar, null, null);
            }
            return ar;

        }