System.Net.Cache.ForwardingReadStream.ICloseEx C# (CSharp) Method

ICloseEx() private method

private ICloseEx ( CloseExState closeState ) : void
closeState CloseExState
return void
        void ICloseEx.CloseEx(CloseExState closeState) {

            if (Interlocked.Increment(ref _Disposed) == 1) {
                // This would allow us to cache the response stream that user throws away
                // Next time the cached version could save us from an extra roundtrip
                if (closeState == CloseExState.Silent) {
                    try {
                        int total = 0;
                        int bytesRead;
                        while (total < ConnectStream.s_DrainingBuffer.Length && (bytesRead = Read(ConnectStream.s_DrainingBuffer, 0, ConnectStream.s_DrainingBuffer.Length)) > 0) {
                            total += bytesRead;
                        }
                    }
                    catch (Exception exception) {
                        //ATTN: this path will swalow errors regardless of m_IsThrowOnWriteError setting
                        //      A "Silent" close is for an intermediate response that is to be ignored anyway
                        if (exception is ThreadAbortException || exception is StackOverflowException || exception is OutOfMemoryException) {
                            throw;
                        }
                    }
                    catch {
                        //ATTN: this path will swalow errors regardless of m_IsThrowOnWriteError setting
                        //      A "Silent" close is for an intermediate response that is to be ignored anyway
                    }
                }

                Dispose(true, closeState);
                GC.SuppressFinalize(this);
            }
        }