[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
        unsafe internal NativeOverlapped *Pack(IOCompletionCallback iocb, Object userData)
        {
            if (!m_pinSelf.IsNull())
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
            }
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            if (iocb != null)
            {
                m_iocbHelper = new _IOCompletionCallback(iocb, ref stackMark);
                m_iocb       = iocb;
            }
            else
            {
                m_iocbHelper = null;
                m_iocb       = null;
            }
            m_userObject = userData;
            if (m_userObject != null)
            {
                if (m_userObject.GetType() == typeof(Object[]))
                {
                    m_isArray = 1;
                }
                else
                {
                    m_isArray = 0;
                }
            }
            return(AllocateNativeOverlapped());
        }
Ejemplo n.º 2
0
        internal unsafe NativeOverlapped *Pack(IOCompletionCallback iocb, object userData)
        {
            if (!this.m_pinSelf.IsNull())
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
            }
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            if (iocb != null)
            {
                this.m_iocbHelper = new _IOCompletionCallback(iocb, ref stackMark);
                this.m_iocb       = iocb;
            }
            else
            {
                this.m_iocbHelper = (_IOCompletionCallback)null;
                this.m_iocb       = (IOCompletionCallback)null;
            }
            this.m_userObject = userData;
            if (this.m_userObject != null)
            {
                this.m_isArray = !(this.m_userObject.GetType() == typeof(object[])) ? (byte)0 : (byte)1;
            }
            return(this.AllocateNativeOverlapped());
        }
Ejemplo n.º 3
0
        unsafe internal NativeOverlapped *Pack(IOCompletionCallback iocb, Object userData)
        {
            if (!m_pinSelf.IsNull())
            {
                throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
            }

            if (iocb != null)
            {
                m_iocbHelper = new _IOCompletionCallback(iocb);
                m_iocb       = iocb;
            }
            else
            {
                m_iocbHelper = null;
                m_iocb       = null;
            }
            m_userObject = userData;
            if (m_userObject != null)
            {
                if (m_userObject.GetType() == typeof(Object[]))
                {
                    m_isArray = 1;
                }
                else
                {
                    m_isArray = 0;
                }
            }
            return(AllocateNativeOverlapped());
        }
Ejemplo n.º 4
0
 internal unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, object userData)
 {
     if (!this.m_pinSelf.IsNull())
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
     }
     StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;
     if (iocb != null)
     {
         this.m_iocbHelper = new _IOCompletionCallback(iocb, ref lookForMyCaller);
         this.m_iocb = iocb;
     }
     else
     {
         this.m_iocbHelper = null;
         this.m_iocb = null;
     }
     this.m_userObject = userData;
     if (this.m_userObject != null)
     {
         if (this.m_userObject.GetType() == typeof(object[]))
         {
             this.m_isArray = 1;
         }
         else
         {
             this.m_isArray = 0;
         }
     }
     return this.AllocateNativeOverlapped();
 }
Ejemplo n.º 5
0
        static internal void IOCompletionCallback_Context(Object state)
        {
            _IOCompletionCallback helper = (_IOCompletionCallback)state;

            Debug.Assert(helper != null, "_IOCompletionCallback cannot be null");
            helper._ioCompletionCallback(helper._errorCode, helper._numBytes, helper._pOVERLAP);
        }
Ejemplo n.º 6
0
        internal unsafe NativeOverlapped *Pack(IOCompletionCallback iocb, Object userData)
        {
            if (m_pinSelf != IntPtr.Zero)
            {
                throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
            }

            if (iocb != null)
            {
                ExecutionContext ec = ExecutionContext.Capture();
                m_iocbHelper = ec != null ? new _IOCompletionCallback(iocb, ec) : null;
                m_iocb       = iocb;
            }
            else
            {
                m_iocbHelper = null;
                m_iocb       = null;
            }
            m_userObject = userData;
            if (m_userObject != null)
            {
                if (m_userObject.GetType() == typeof(Object[]))
                {
                    m_isArray = 1;
                }
                else
                {
                    m_isArray = 0;
                }
            }
            return(AllocateNativeOverlapped());
        }
Ejemplo n.º 7
0
        private static void IOCompletionCallback_Context(object?state)
        {
            _IOCompletionCallback helper = (_IOCompletionCallback)state !;

            Debug.Assert(helper != null, "_IOCompletionCallback cannot be null");
            helper._ioCompletionCallback(helper._errorCode, helper._numBytes, helper._pNativeOverlapped);
        }
Ejemplo n.º 8
0
 internal unsafe NativeOverlapped *Pack(IOCompletionCallback iocb, Object userData)
 {
     if (!m_pinSelf.IsNull())
     {
         throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
     }
     m_iocb       = iocb;
     m_iocbHelper = (iocb != null) ? new _IOCompletionCallback(iocb) : null;
     m_userObject = userData;
     return(AllocateNativeOverlapped());
 }
Ejemplo n.º 9
0
 internal unsafe NativeOverlapped *UnsafePack(IOCompletionCallback iocb, Object userData)
 {
     if (m_pinSelf != IntPtr.Zero)
     {
         throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
     }
     m_iocb       = iocb;
     m_iocbHelper = null;
     m_userObject = userData;
     return(AllocateNativeOverlapped());
 }
Ejemplo n.º 10
0
 internal void ReInitialize()
 {
     m_asyncResult = null;
     m_iocb        = null;
     m_iocbHelper  = null;
     m_overlapped  = null;
     m_userObject  = null;
     Debug.Assert(m_pinSelf == IntPtr.Zero, "OverlappedData has not been freed: m_pinSelf");
     m_pinSelf = IntPtr.Zero;
     // Reuse m_pinnedData array
     m_nativeOverlapped = default(NativeOverlapped);
 }
Ejemplo n.º 11
0
 internal void ReInitialize()
 {
     this.m_asyncResult = null;
     this.m_iocb = null;
     this.m_iocbHelper = null;
     this.m_overlapped = null;
     this.m_userObject = null;
     this.m_pinSelf = IntPtr.Zero;
     this.m_userObjectInternal = IntPtr.Zero;
     this.m_AppDomainId = 0;
     this.m_nativeOverlapped.EventHandle = IntPtr.Zero;
     this.m_isArray = 0;
     this.m_nativeOverlapped.InternalHigh = IntPtr.Zero;
 }
 internal void ReInitialize()
 {
     this.m_asyncResult                   = null;
     this.m_iocb                          = null;
     this.m_iocbHelper                    = null;
     this.m_overlapped                    = null;
     this.m_userObject                    = null;
     this.m_pinSelf                       = IntPtr.Zero;
     this.m_userObjectInternal            = IntPtr.Zero;
     this.m_AppDomainId                   = 0;
     this.m_nativeOverlapped.EventHandle  = IntPtr.Zero;
     this.m_isArray                       = 0;
     this.m_nativeOverlapped.InternalHigh = IntPtr.Zero;
 }
Ejemplo n.º 13
0
 internal void ReInitialize()
 {
     this.m_asyncResult                   = (IAsyncResult)null;
     this.m_iocb                          = (IOCompletionCallback)null;
     this.m_iocbHelper                    = (_IOCompletionCallback)null;
     this.m_overlapped                    = (Overlapped)null;
     this.m_userObject                    = (object)null;
     this.m_pinSelf                       = (IntPtr)0;
     this.m_userObjectInternal            = (IntPtr)0;
     this.m_AppDomainId                   = 0;
     this.m_nativeOverlapped.EventHandle  = (IntPtr)0;
     this.m_isArray                       = (byte)0;
     this.m_nativeOverlapped.InternalLow  = (IntPtr)0;
     this.m_nativeOverlapped.InternalHigh = (IntPtr)0;
 }
Ejemplo n.º 14
0
 internal unsafe NativeOverlapped *UnsafePack(IOCompletionCallback iocb, object userData)
 {
     if (!this.m_pinSelf.IsNull())
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
     }
     this.m_userObject = userData;
     if (this.m_userObject != null)
     {
         this.m_isArray = !(this.m_userObject.GetType() == typeof(object[])) ? (byte)0 : (byte)1;
     }
     this.m_iocb       = iocb;
     this.m_iocbHelper = (_IOCompletionCallback)null;
     return(this.AllocateNativeOverlapped());
 }
Ejemplo n.º 15
0
 internal void ReInitialize()
 {
     m_asyncResult = null;
     m_iocb        = null;
     m_iocbHelper  = null;
     m_overlapped  = null;
     m_userObject  = null;
     BCLDebug.Assert(m_pinSelf.IsNull(), "OverlappedData has not been freed: m_pinSelf");
     m_pinSelf            = (IntPtr)0;
     m_userObjectInternal = (IntPtr)0;
     BCLDebug.Assert(m_AppDomainId == 0 || m_AppDomainId == AppDomain.CurrentDomain.Id, "OverlappedData is not in the current domain");
     m_AppDomainId = 0;
     m_nativeOverlapped.EventHandle = (IntPtr)0;
     m_isArray = 0;
     m_nativeOverlapped.InternalHigh = (IntPtr)0;
 }
Ejemplo n.º 16
0
 internal static unsafe void PerformIOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped *pOVERLAP)
 {
     do
     {
         Overlapped            overlapped = OverlappedData.GetOverlappedFromNative(pOVERLAP).m_overlapped;
         _IOCompletionCallback iocbHelper = overlapped.iocbHelper;
         if (((iocbHelper == null) || (iocbHelper._executionContext == null)) || iocbHelper._executionContext.IsDefaultFTContext())
         {
             overlapped.UserCallback(errorCode, numBytes, pOVERLAP);
         }
         else
         {
             iocbHelper._errorCode = errorCode;
             iocbHelper._numBytes  = numBytes;
             iocbHelper._pOVERLAP  = pOVERLAP;
             ExecutionContext.Run(iocbHelper._executionContext.CreateCopy(), _ccb, iocbHelper);
         }
         OverlappedData.CheckVMForIOPacket(out pOVERLAP, out errorCode, out numBytes);
     }while (pOVERLAP != null);
 }
Ejemplo n.º 17
0
 internal static unsafe void PerformIOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped *pOVERLAP)
 {
     do
     {
         Overlapped            overlapped = OverlappedData.GetOverlappedFromNative(pOVERLAP).m_overlapped;
         _IOCompletionCallback iocbHelper = overlapped.iocbHelper;
         if (iocbHelper == null || iocbHelper._executionContext == null || iocbHelper._executionContext.IsDefaultFTContext(true))
         {
             overlapped.UserCallback(errorCode, numBytes, pOVERLAP);
         }
         else
         {
             iocbHelper._errorCode = errorCode;
             iocbHelper._numBytes  = numBytes;
             iocbHelper._pOVERLAP  = pOVERLAP;
             using (ExecutionContext copy = iocbHelper._executionContext.CreateCopy())
                 ExecutionContext.Run(copy, _IOCompletionCallback._ccb, (object)iocbHelper, true);
         }
         OverlappedData.CheckVMForIOPacket(out pOVERLAP, out errorCode, out numBytes);
     }while ((IntPtr)pOVERLAP != IntPtr.Zero);
 }
 unsafe internal NativeOverlapped *UnsafePack(IOCompletionCallback iocb, Object userData)
 {
     if (!m_pinSelf.IsNull())
     {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
     }
     m_userObject = userData;
     if (m_userObject != null)
     {
         if (m_userObject.GetType() == typeof(Object[]))
         {
             m_isArray = 1;
         }
         else
         {
             m_isArray = 0;
         }
     }
     m_iocb       = iocb;
     m_iocbHelper = null;
     return(AllocateNativeOverlapped());
 }
Ejemplo n.º 19
0
 internal unsafe NativeOverlapped *UnsafePack(IOCompletionCallback iocb, Object userData)
 {
     if (m_pinSelf != IntPtr.Zero)
     {
         throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack);
     }
     m_userObject = userData;
     if (m_userObject != null)
     {
         if (m_userObject.GetType() == typeof(Object[]))
         {
             m_isArray = 1;
         }
         else
         {
             m_isArray = 0;
         }
     }
     m_iocb       = iocb;
     m_iocbHelper = null;
     return(AllocateNativeOverlapped());
 }
Ejemplo n.º 20
0
        // call back helper
        static unsafe internal void PerformIOCompletionCallback(uint errorCode,            // Error code
                                                                uint numBytes,             // No. of bytes transferred
                                                                NativeOverlapped *pOVERLAP // ptr to OVERLAP structure
                                                                )
        {
            Overlapped            overlapped = OverlappedData.GetOverlappedFromNative(pOVERLAP).m_overlapped;
            _IOCompletionCallback helper     = overlapped.iocbHelper;

            if (helper == null || helper._executionContext == null || helper._executionContext.IsDefaultFTContext())
            {
                // We got here because of UnsafePack (or) Pack with EC flow supressed
                IOCompletionCallback callback = overlapped.UserCallback;
                callback(errorCode, numBytes, pOVERLAP);
            }
            else
            {
                // We got here because of Pack
                helper._errorCode = errorCode;
                helper._numBytes  = numBytes;
                helper._pOVERLAP  = pOVERLAP;
                ExecutionContext.Run(helper._executionContext.CreateCopy(), _ccb, helper);
            }
        }
Ejemplo n.º 21
0
        internal static void IOCompletionCallback_Context(object state)
        {
            _IOCompletionCallback iocompletionCallback = (_IOCompletionCallback)state;

            iocompletionCallback._ioCompletionCallback(iocompletionCallback._errorCode, iocompletionCallback._numBytes, iocompletionCallback._pOVERLAP);
        }
Ejemplo n.º 22
0
 unsafe internal NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData)
 {            
     if (!m_pinSelf.IsNull()) {
         throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack"));
     }
     m_userObject = userData;
     if (m_userObject != null)
     {
         if (m_userObject.GetType() == typeof(Object[]))
         {
             m_isArray = 1;
         }
         else
         {
             m_isArray = 0;
         }
     }
     m_iocb = iocb;
     m_iocbHelper = null;
     return AllocateNativeOverlapped();
 }
Ejemplo n.º 23
0
 internal void ReInitialize()
 {
     m_asyncResult = null;
     m_iocb = null;
     m_iocbHelper = null;
     m_overlapped = null;
     m_userObject = null;
     Debug.Assert(m_pinSelf.IsNull(), "OverlappedData has not been freed: m_pinSelf");
     m_pinSelf = (IntPtr)0;
     m_userObjectInternal = (IntPtr)0;
     Debug.Assert(m_AppDomainId == 0 || m_AppDomainId == AppDomain.CurrentDomain.Id, "OverlappedData is not in the current domain");
     m_AppDomainId = 0;
     m_nativeOverlapped.EventHandle = (IntPtr)0;
     m_isArray = 0;
     m_nativeOverlapped.InternalLow = (IntPtr)0;
     m_nativeOverlapped.InternalHigh = (IntPtr)0;
 }
Ejemplo n.º 24
0
        internal static unsafe void IOCompletionCallback_Context(object state)
        {
            _IOCompletionCallback callback = (_IOCompletionCallback)state;

            callback._ioCompletionCallback(callback._errorCode, callback._numBytes, callback._pOVERLAP);
        }