Esempio n. 1
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;
            _IOCompletionCallback helper;

            do
            {
                overlapped = OverlappedData.GetOverlappedFromNative(pOVERLAP).m_overlapped;
                helper     = overlapped.iocbHelper;

                if (helper == null || helper._executionContext == null || helper._executionContext == ExecutionContext.Default)
                {
                    // 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, _ccb, helper);
                }

                //Quickly check the VM again, to see if a packet has arrived.
                OverlappedData.CheckVMForIOPacket(out pOVERLAP, out errorCode, out numBytes);
            } while (pOVERLAP != null);
        }
Esempio n. 2
0
        // call back helper
        internal static unsafe void PerformIOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped *pNativeOverlapped)
        {
            do
            {
                OverlappedData overlapped = OverlappedData.GetOverlappedFromNative(pNativeOverlapped);

                if (overlapped._callback is IOCompletionCallback iocb)
                {
                    // We got here because of UnsafePack (or) Pack with EC flow suppressed
                    iocb(errorCode, numBytes, pNativeOverlapped);
                }
                else
                {
                    // We got here because of Pack
                    var helper = (_IOCompletionCallback)overlapped._callback;
                    helper._errorCode         = errorCode;
                    helper._numBytes          = numBytes;
                    helper._pNativeOverlapped = pNativeOverlapped;
                    ExecutionContext.RunInternal(helper._executionContext, _ccb, helper);
                }

                //Quickly check the VM again, to see if a packet has arrived.
                OverlappedData.CheckVMForIOPacket(out pNativeOverlapped, out errorCode, out numBytes);
            } while (pNativeOverlapped != null);
        }
Esempio n. 3
0
        // call back helper
        internal static void PerformIOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped *pNativeOverlapped)
        {
            do
            {
                OverlappedData overlapped = OverlappedData.GetOverlappedFromNative(pNativeOverlapped);

                if (overlapped._callback is IOCompletionCallback iocb)
                {
                    // We got here because of UnsafePack (or) Pack with EC flow suppressed
                    iocb(errorCode, numBytes, pNativeOverlapped);
                }
                else
                {
                    // We got here because of Pack
                    var helper = (_IOCompletionCallback?)overlapped._callback;
                    Debug.Assert(helper != null, "Should only be receiving a completion callback if a delegate was provided.");
                    helper._errorCode         = errorCode;
                    helper._numBytes          = numBytes;
                    helper._pNativeOverlapped = pNativeOverlapped;
                    ExecutionContext.RunInternal(helper._executionContext, IOCompletionCallback_Context_Delegate, helper);
                }

                // Quickly check the VM again, to see if a packet has arrived.
                OverlappedData.CheckVMForIOPacket(out pNativeOverlapped, out errorCode, out numBytes);
            } while (pNativeOverlapped != null);
        }
 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);
 }
Esempio n. 5
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);
 }