public unsafe PreAllocatedOverlapped(IOCompletionCallback callback, object state, object pinData)
        {
            if (callback == null)
                throw new ArgumentNullException("callback");

            _overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, this);
        }
        private static unsafe void CompletionCallback(
            uint errorCode,
            uint numBytes,
            NativeOverlapped *nativeOverlapped
            )
        {
            ThreadPoolBoundHandleOverlapped overlapped =
                (ThreadPoolBoundHandleOverlapped)Overlapped.Unpack(nativeOverlapped);

            //
            // The Win32 thread pool implementation of ThreadPoolBoundHandle does not permit reuse of NativeOverlapped
            // pointers without freeing them and allocating new a new one.  We need to ensure that code using the CLR
            // ThreadPool implementation follows those rules.
            //
            if (overlapped._completed)
            {
                throw new InvalidOperationException(SR.InvalidOperation_NativeOverlappedReused);
            }

            overlapped._completed = true;

            if (overlapped._boundHandle == null)
            {
                throw new InvalidOperationException(SR.Argument_NativeOverlappedAlreadyFree);
            }

            overlapped._userCallback(errorCode, numBytes, nativeOverlapped);
        }
        public PreAllocatedOverlapped(IOCompletionCallback callback, object?state, object?pinData)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            _overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, this);
        }
Exemplo n.º 4
0
        private PreAllocatedOverlapped(IOCompletionCallback callback, object?state, object?pinData, bool flowExecutionContext)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            _overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, this, flowExecutionContext);
        }
Exemplo n.º 5
0
        private PreAllocatedOverlapped(IOCompletionCallback callback, object?state, object?pinData, bool flowExecutionContext)
        {
            ArgumentNullException.ThrowIfNull(callback);

            _overlapped = new ThreadPoolBoundHandleOverlapped(callback, state, pinData, this, flowExecutionContext);
        }