public Trigger CreateTrigger()
		{
			Interlocked.Increment(ref _outstandingTriggers);
			SingleEntryGate triggerGate = new SingleEntryGate();

			return new Trigger(() => {
				if (triggerGate.TryEnter())
					HandleTriggerFired();
			});
		}
 private void HandleTriggerFired()
 {
     if (Interlocked.Decrement(ref _outstandingTriggers) == 0)
     {
         if (_continuationGate.TryEnter())
         {
             _continuation();
         }
     }
 }
        public Trigger CreateTrigger()
        {
            Interlocked.Increment(ref _outstandingTriggers);
            SingleEntryGate triggerGate = new SingleEntryGate();

            return(new Trigger(() => {
                if (triggerGate.TryEnter())
                {
                    HandleTriggerFired();
                }
            }));
        }