예제 #1
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            int read = _stream.EndRead(asyncResult);

            _position += read;
            return(read);
        }
예제 #2
0
        // async tests (for stack propagation)

        private void ReadCallback(IAsyncResult ar)
        {
            GZipStream s = (GZipStream)ar.AsyncState;

            s.EndRead(ar);
            try {
                // can we do something bad here ?
                Assert.IsNotNull(Environment.GetEnvironmentVariable("USERNAME"));
                message = "Expected a SecurityException";
            }
            catch (SecurityException) {
                message = null;
                reset.Set();
            }
            catch (Exception e) {
                message = e.ToString();
            }
        }
예제 #3
0
        void dataReceived(IAsyncResult i)
        {
            byte[] buffer = (byte[])i.AsyncState;
            int    nBytes = 0;

            try
            {
                if (tcpStreamGzipRead != null)
                {
                    nBytes = tcpStreamGzipRead.EndRead(i);
                }
                else
                {
                    nBytes = tcpStream.EndRead(i);
                }
                if (nBytes != 0)
                {
                    processBytes(buffer, nBytes);
                }
            }
            catch (Exception Ex)
            {
                if (Ex is InvalidOperationException)
                {
                    //  MessageBox.Show( Ex.ToString(),"Exception reading data from server");

                    if (this.appwin != null)
                    {
                        this.appwin.pleaseClose();
                    }
                }
                else
                {
                    Console.WriteLine(Ex.Message); // Silently carry on .....
                }
            }
            startStreamAsyncRead();
        }