Exemple #1
0
        public unsafe NativeOverlapped *AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
        {
            if (preAllocated == null)
            {
                throw new ArgumentNullException(nameof(preAllocated));
            }

            EnsureNotDisposed();

            preAllocated.AddRef();
            try
            {
                ThreadPoolBoundHandleOverlapped overlapped = preAllocated._overlapped;

                if (overlapped._boundHandle != null)
                {
                    throw new ArgumentException(Environment.GetResourceString("Argument_PreAllocatedAlreadyAllocated"), nameof(preAllocated));
                }

                overlapped._boundHandle = this;

                return(overlapped._nativeOverlapped);
            }
            catch
            {
                preAllocated.Release();
                throw;
            }
        }
        public unsafe NativeOverlapped *AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
        {
            ArgumentNullException.ThrowIfNull(preAllocated);

            EnsureNotDisposed();

            preAllocated.AddRef();
            try
            {
                ThreadPoolBoundHandleOverlapped overlapped = preAllocated._overlapped;

                if (overlapped._boundHandle != null)
                {
                    throw new ArgumentException(SR.Argument_PreAllocatedAlreadyAllocated, nameof(preAllocated));
                }

                overlapped._boundHandle = this;

                return(overlapped._nativeOverlapped);
            }
            catch
            {
                preAllocated.Release();
                throw;
            }
        }
Exemple #3
0
        public unsafe NativeOverlapped *AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
        {
            if (preAllocated == null)
            {
                throw new ArgumentNullException("preAllocated");
            }
            this.EnsureNotDisposed();
            preAllocated.AddRef();
            NativeOverlapped *nativeOverlapped;

            try
            {
                ThreadPoolBoundHandleOverlapped expr_21 = preAllocated._overlapped;
                if (expr_21._boundHandle != null)
                {
                    throw new ArgumentException("Already Allocated", "preAllocated");
                }
                expr_21._boundHandle = this;
                nativeOverlapped     = expr_21._nativeOverlapped;
            }
            catch
            {
                preAllocated.Release();
                throw;
            }
            return(nativeOverlapped);
        }
Exemple #4
0
        public unsafe NativeOverlapped *AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
        {
            if (preAllocated == null)
            {
                throw new ArgumentNullException(nameof(preAllocated));
            }

            bool addedRefToThis         = false;
            bool addedRefToPreAllocated = false;

            try
            {
                addedRefToThis         = AddRef();
                addedRefToPreAllocated = preAllocated.AddRef();

                Win32ThreadPoolNativeOverlapped.OverlappedData data = preAllocated._overlapped->Data;
                if (data._boundHandle != null)
                {
                    throw new ArgumentException(SR.Argument_PreAllocatedAlreadyAllocated, nameof(preAllocated));
                }

                data._boundHandle = this;

                Interop.mincore.StartThreadpoolIo(_threadPoolHandle);

                return(Win32ThreadPoolNativeOverlapped.ToNativeOverlapped(preAllocated._overlapped));
            }
            catch
            {
                if (addedRefToPreAllocated)
                {
                    preAllocated.Release();
                }
                if (addedRefToThis)
                {
                    Release();
                }
                throw;
            }
        }
        public unsafe NativeOverlapped* AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
        {
            if (preAllocated == null)
                throw new ArgumentNullException("preAllocated");

            bool addedRefToThis = false;
            bool addedRefToPreAllocated = false;
            try
            {
                addedRefToThis = AddRef();
                addedRefToPreAllocated = preAllocated.AddRef();

                Win32ThreadPoolNativeOverlapped.OverlappedData data = preAllocated._overlapped->Data;
                if (data._boundHandle != null)
                    throw new ArgumentException(SR.Argument_PreAllocatedAlreadyAllocated, "preAllocated");

                data._boundHandle = this;

                Interop.mincore.StartThreadpoolIo(_threadPoolHandle);

                return Win32ThreadPoolNativeOverlapped.ToNativeOverlapped(preAllocated._overlapped);
            }
            catch
            {
                if (addedRefToPreAllocated)
                    preAllocated.Release();
                if (addedRefToThis)
                    Release();
                throw;
            }
        }
        public unsafe NativeOverlapped* AllocateNativeOverlapped(PreAllocatedOverlapped preAllocated)
        {
            if (preAllocated == null)
                throw new ArgumentNullException("preAllocated");

            EnsureNotDisposed();

            preAllocated.AddRef();
            try
            {
                ThreadPoolBoundHandleOverlapped overlapped = preAllocated._overlapped;

                if (overlapped._boundHandle != null)
                    throw new ArgumentException(SR.Argument_PreAllocatedAlreadyAllocated, "preAllocated");

                overlapped._boundHandle = this;

                return overlapped._nativeOverlapped;
            }
            catch
            {
                preAllocated.Release();
                throw;
            }
        }