protected override void OnEventWritten(EventWrittenEventArgs eventData)
        {
            if (!Thread.CurrentThread.IsThreadPoolThread)
            {
                return;
            }

            if (eventData.EventId == 10 && // TASKWAITBEGIN_ID
                eventData.Payload != null &&
                eventData.Payload.Count > 3 &&
                eventData.Payload[3] is int value && // Behavior
                value == 1)                          // TaskWaitBehavior.Synchronous
            {
                t_recursionCount++;
                _monitor.BlockingStart(DectectionSource.EventListener);
            }
        public override int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
        {
            if (millisecondsTimeout == 0)
            {
                return(WaitInternal(waitHandles, waitAll, millisecondsTimeout));
            }

            _monitor.BlockingStart(DectectionSource.SynchronizationContext);

            try
            {
                return(WaitInternal(waitHandles, waitAll, millisecondsTimeout));
            }
            finally
            {
                _monitor.BlockingEnd();
            }
        }
Esempio n. 3
0
        public override int Wait(IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
        {
            _monitor.BlockingStart(DectectionSource.SynchronizationContext);

            try
            {
                if (_syncCtx != null)
                {
                    return(_syncCtx.Wait(waitHandles, waitAll, millisecondsTimeout));
                }
                else
                {
                    return(base.Wait(waitHandles, waitAll, millisecondsTimeout));
                }
            }
            finally
            {
                _monitor.BlockingEnd();
            }
        }