System.Net.FtpDataStream.AsyncReadCallback C# (CSharp) Method

AsyncReadCallback() private method

private AsyncReadCallback ( IAsyncResult ar ) : void
ar IAsyncResult
return void
        private void AsyncReadCallback(IAsyncResult ar)
        {
            LazyAsyncResult userResult = (LazyAsyncResult)ar.AsyncState;
            try
            {
                try
                {
                    int readBytes = _networkStream.EndRead(ar);
                    if (readBytes == 0)
                    {
                        _isFullyRead = true;
                        Close(); // This should block for pipeline completion
                    }
                    userResult.InvokeCallback(readBytes);
                }
                catch (Exception exception)
                {
                    // Complete with error. If already completed rethrow on the worker thread
                    if (!userResult.IsCompleted)
                        userResult.InvokeCallback(exception);
                }
            }
            catch { }
        }