Esempio n. 1
0
 protected override void OnEventWritten(EventWrittenEventArgs eventData)
 {
     if (listenForCurrentContext && CurrentContextEvents.IsEntered())
     {
         this.OnOnEventWritten(eventData);
     }
 }
Esempio n. 2
0
 public override void Dispose()
 {
     if (listenForCurrentContext)
     {
         CurrentContextEvents.Exit();
     }
     base.Dispose();
 }
Esempio n. 3
0
        public TestEventListener(bool waitForDelayedEvents = true, bool listenForCurrentContext = true)
        {
            this.events                  = new ConcurrentQueue <EventWrittenEventArgs>();
            this.eventWritten            = new AutoResetEvent(false);
            this.waitForDelayedEvents    = waitForDelayedEvents;
            this.listenForCurrentContext = listenForCurrentContext;
            this.OnOnEventWritten        = e =>
            {
                this.events.Enqueue(e);
                this.eventWritten.Set();
            };

            if (this.listenForCurrentContext)
            {
                CurrentContextEvents.Enter();
            }
        }