System.Net.AsyncProtocolRequest.CompleteRequest C# (CSharp) Method

CompleteRequest() private method

private CompleteRequest ( int result ) : void
result int
return void
        internal void CompleteRequest(int result)
        {
            Result = result;
            int status = Interlocked.Exchange(ref _completionStatus, StatusCompleted);
            if (status == StatusCompleted)
            {
                throw new InternalException(); // Only allow one call.
            }

            if (status == StatusCheckedOnSyncCompletion)
            {
                _completionStatus = StatusNotStarted;
                _callback(this);
            }
        }

Usage Example

Beispiel #1
0
        private bool CheckCompletionBeforeNextRead(int bytes)
        {
            if (bytes == 0)
            {
                // 0 bytes was requested or EOF in the beginning of a frame, the caller should decide whether it's OK.
                if (_totalRead == 0)
                {
                    _request.CompleteRequest(0);
                    return(true);
                }

                // EOF in the middle of a frame.
                throw new IOException(SR.net_io_eof);
            }

            if (_totalRead + bytes > _request.Count)
            {
                if (GlobalLog.IsEnabled)
                {
                    GlobalLog.AssertFormat("FixedSizeReader::CheckCompletion()|State got out of range. Total:{0} Count:{1}", _totalRead + bytes, _request.Count);
                }
                Debug.Fail("FixedSizeReader::CheckCompletion()|State got out of range. Total:" + (_totalRead + bytes) + " Count:" + _request.Count);
            }

            if ((_totalRead += bytes) == _request.Count)
            {
                _request.CompleteRequest(_request.Count);
                return(true);
            }

            return(false);
        }
All Usage Examples Of System.Net.AsyncProtocolRequest::CompleteRequest