System.Net.WebSockets.WebSocketHttpListenerDuplexStream.HttpListenerAsyncEventArgs.FinishOperationSuccess C# (CSharp) Method

FinishOperationSuccess() private method

private FinishOperationSuccess ( int bytesTransferred, bool syncCompletion ) : void
bytesTransferred int
syncCompletion bool
return void
            internal void FinishOperationSuccess(int bytesTransferred, bool syncCompletion)
            {
                SetResults(null, bytesTransferred);

                if (NetEventSource.IsEnabled)
                {
                    if (_buffer != null && NetEventSource.IsEnabled)
                    {
                        string methodName = _completedOperation == HttpListenerAsyncOperation.Receive ? nameof(ReadAsyncFast) : nameof(WriteAsyncFast);
                        NetEventSource.DumpBuffer(_currentStream, _buffer, _offset, bytesTransferred, methodName);
                    }
                    else if (_bufferList != null)
                    {
                        Debug.Assert(_completedOperation == HttpListenerAsyncOperation.Send,
                            "'BufferList' is only supported for send operations.");

                        foreach (ArraySegment<byte> buffer in BufferList)
                        {
                            NetEventSource.DumpBuffer(this, buffer.Array, buffer.Offset, buffer.Count, nameof(WriteAsyncFast));
                        }
                    }
                }

                if (_shouldCloseOutput)
                {
                    _currentStream._outputStream.SetClosedFlag();
                }

                // Complete the operation and raise completion event.
                Complete();
                OnCompleted(this);
            }