System.Net.AsyncRequestContext.Allocate C# (CSharp) Method

Allocate() private method

private Allocate ( ThreadPoolBoundHandle boundHandle, uint size ) : Interop.HttpApi.HTTP_REQUEST*
boundHandle System.Threading.ThreadPoolBoundHandle
size uint
return Interop.HttpApi.HTTP_REQUEST*
        private Interop.HttpApi.HTTP_REQUEST* Allocate(ThreadPoolBoundHandle boundHandle, uint size)
        {
            uint newSize = size != 0 ? size : RequestBuffer == null ? 4096 : Size;
            if (_nativeOverlapped != null && newSize != RequestBuffer.Length)
            {
                NativeOverlapped* nativeOverlapped = _nativeOverlapped;
                _nativeOverlapped = null;
                _boundHandle.FreeNativeOverlapped(nativeOverlapped);
            }
            if (_nativeOverlapped == null)
            {
                SetBuffer(checked((int)newSize));
                _boundHandle = boundHandle;
                _nativeOverlapped = boundHandle.AllocateNativeOverlapped(ListenerAsyncResult.IOCallback, state: _result, pinData: RequestBuffer);
                return (Interop.HttpApi.HTTP_REQUEST*)Marshal.UnsafeAddrOfPinnedArrayElement(RequestBuffer, 0);
            }
            return RequestBlob;
        }