System.Net.FtpWebRequest.DataStreamClosed C# (CSharp) Method

DataStreamClosed() private method

private DataStreamClosed ( CloseExState closeState ) : void
closeState CloseExState
return void
        internal void DataStreamClosed(CloseExState closeState)
        {
            if ((closeState & CloseExState.Abort) == 0)
            {
                if (!_async)
                {
                    if (_connection != null)
                        _connection.CheckContinuePipeline();
                }
                else
                {
                    _requestCompleteAsyncResult.InternalWaitForCompletion();
                    CheckError();
                }
            }
            else
            {
                FtpControlStream connection = _connection;
                if (connection != null)
                    connection.Abort(ExceptionHelper.RequestAbortedException);
            }
        }
    }  // class FtpWebRequest

Usage Example

        void ICloseEx.CloseEx(CloseExState closeState)
        {
            GlobalLog.Print("FtpDataStream#" + ValidationHelper.HashString(this) + "::CloseEx, state = " + closeState.ToString());

            lock (this)
            {
                if (m_Closing == true)
                {
                    return;
                }
                m_Closing   = true;
                m_Writeable = false;
                m_Readable  = false;
            }

            try {
                try {
                    if ((closeState & CloseExState.Abort) == 0)
                    {
                        m_NetworkStream.Close(Socket.DefaultCloseTimeout);
                    }
                    else
                    {
                        m_NetworkStream.Close(0);
                    }
                } finally {
                    m_Request.DataStreamClosed(closeState);
                }
            }
            catch (Exception exception) {
                bool         doThrow      = true;
                WebException webException = exception as WebException;
                if (webException != null)
                {
                    FtpWebResponse response = webException.Response as FtpWebResponse;
                    if (response != null)
                    {
                        if (!m_IsFullyRead &&
                            response.StatusCode == FtpStatusCode.ConnectionClosed)
                        {
                            doThrow = false;
                        }
                    }
                }

                if (doThrow)
                {
                    if ((closeState & CloseExState.Silent) == 0)
                    {
                        throw;
                    }
                }
            }
        }
All Usage Examples Of System.Net.FtpWebRequest::DataStreamClosed