/// <summary> /// Our thread proc for removing items from the event /// queue and sending them on. Note that this would /// need to do more locking if any other thread were /// removing events from the queue. /// </summary> private void PumpThreadProc() { EventListener hostListeners = CoreExtensions.Host.Listeners; try { while (true) { Event e = this.events.Dequeue(this.PumpState == EventPumpState.Pumping); if (e == null) { break; } try { e.Send(this.eventListener); e.Send(hostListeners); } catch (Exception ex) { log.Error("Exception in event handler", ex); } finally { if (e.IsSynchronous) { this.synchronousEventSent.Set(); } } if (this.autostop && e is RunFinishedEvent) { this.PumpState = EventPumpState.Stopping; } } } catch (Exception ex) { log.Error("Exception in pump thread", ex); } finally { this.PumpState = EventPumpState.Stopped; //pumpThread = null; } }
/// <summary> /// Our thread proc for removing items from the event /// queue and sending them on. Note that this would /// need to do more locking if any other thread were /// removing events from the queue. /// </summary> private void PumpThreadProc() { EventListener hostListeners = CoreExtensions.Host.Listeners; Monitor.Enter(events); try { while (this.events.Count > 0 || !stopping) { while (this.events.Count > 0) { Event e = this.events.Dequeue(); e.Send(this.eventListener); e.Send(hostListeners); if (autostop && e is RunFinishedEvent) { stopping = true; } } // Will be pulsed if there are any events added // or if it's time to stop the pump. if (!stopping) { Monitor.Wait(events); } } } catch (Exception ex) { throw new ApplicationException("Exception in pump thread", ex); } finally { Monitor.Exit(events); pumping = false; stopping = false; //pumpThread = null; } }
/// <summary> /// Our thread proc for removing items from the event /// queue and sending them on. Note that this would /// need to do more locking if any other thread were /// removing events from the queue. /// </summary> private void PumpThreadProc() { EventListener hostListeners = CoreExtensions.Host.Listeners; Monitor.Enter(events); try { while (this.events.Count > 0 || pumpState == EventPumpState.Pumping) { while (this.events.Count > 0) { Event e = this.events.Dequeue(); e.Send(this.eventListener); e.Send(hostListeners); if (autostop && e is RunFinishedEvent) { pumpState = EventPumpState.Stopping; } } // Will be pulsed if there are any events added // or if it's time to stop the pump. if (pumpState != EventPumpState.Stopping) { Monitor.Wait(events); } } } catch (Exception ex) { log.Error("Exception in pump thread", ex); } finally { Monitor.Exit(events); pumpState = EventPumpState.Stopped; //pumpThread = null; } }