Beispiel #1
0
 private void HandleTriggerFired()
 {
     if (Interlocked.Decrement(ref _outstandingTriggers) == 0)
     {
         if (_continuationFiredGate.TryEnter())
         {
             _continuation();
         }
     }
 }
        public Trigger CreateTrigger() {
            Interlocked.Increment(ref _outstandingTriggers);

            SingleEntryGate triggerFiredGate = new SingleEntryGate();
            return new Trigger(() => {
                if (triggerFiredGate.TryEnter()) {
                    HandleTriggerFired();
                }
            });
        }
            private void ExecuteAsynchronousCallback(bool timedOut)
            {
                WaitForBeginToCompleteAndDestroyTimer();

                if (_handleCallbackGate.TryEnter())
                {
                    _timedOut = timedOut;
                    if (_originalCallback != null)
                    {
                        _originalCallback(this);
                    }
                }
            }
Beispiel #4
0
        public Trigger CreateTrigger()
        {
            Interlocked.Increment(ref _outstandingTriggers);

            SingleEntryGate triggerFiredGate = new SingleEntryGate();

            return(new Trigger(() => {
                if (triggerFiredGate.TryEnter())
                {
                    HandleTriggerFired();
                }
            }));
        }
            public TResult End()
            {
                if (!_endExecutedGate.TryEnter())
                {
                    throw Error.AsyncCommon_AsyncResultAlreadyConsumed();
                }

                if (_timedOut)
                {
                    throw new TimeoutException();
                }
                WaitForBeginToCompleteAndDestroyTimer();

                return _endDelegate(_innerAsyncResult);
            }