Example #1
0
        // call back helper
        internal void ThreadStart(object?obj)
        {
            Debug.Assert(_start is ParameterizedThreadStart);
            _startArg = obj;

            ExecutionContext?context = _executionContext;

            if (context != null)
            {
                ExecutionContext.RunInternal(context, s_threadStartContextCallback, this);
            }
            else
            {
                InitializeCulture();
                ((ParameterizedThreadStart)_start)(obj);
            }
        }
Example #2
0
        internal void CallCallback()
        {
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.ThreadTransfer))
            {
                FrameworkEventSource.Log.ThreadTransferReceiveObj(this, 1, string.Empty);
            }

            // call directly if EC flow is suppressed
            ExecutionContext context = m_executionContext;

            if (context == null)
            {
                m_timerCallback(m_state);
            }
            else
            {
                ExecutionContext.RunInternal(context, s_callCallbackInContext, this);
            }
        }
Example #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, _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);
        }
Example #4
0
 internal static void Run(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)
 {
     ExecutionContext.RunInternal(executionContext, callback, state, preserveSyncCtx);
 }