public void PollEvents() { try { while (!waitingEvents.IsCompleted) { object @event; try { @event = waitingEvents.Take(); } catch (InvalidOperationException e) { if (waitingEvents.IsCompleted) { break; } LOG.Error("Error taking event from queue", e); continue; } try { if (@event is ClientConnection.WatcherSetEventPair) { // each watcher will process the event ClientConnection.WatcherSetEventPair pair = (ClientConnection.WatcherSetEventPair)@event; foreach (IWatcher watcher in pair.watchers) { try { watcher.Process(pair.@event); } catch (Exception t) { LOG.Error("Error while calling watcher ", t); } } } } catch (OperationCanceledException) { //ignored } catch (Exception t) { LOG.Error("Caught unexpected throwable", t); } } } catch (ThreadInterruptedException e) { LOG.Error("Event thread exiting due to interruption", e); } LOG.Info("EventThread shut down"); }
public void QueueEvent(WatchedEvent @event) { if (@event.Type == EventType.None && sessionState == @event.State) { return; } sessionState = @event.State; // materialize the watchers based on the event var pair = new ClientConnection.WatcherSetEventPair(conn.watcher.Materialize(@event.State, @event.Type, @event.Path), @event); // queue the pair (watch set & event) for later processing AppendToQueue(pair); }
public void PollEvents() { try { while (!waitingEvents.IsCompleted) { try { ClientConnection.WatcherSetEventPair pair = null; if (waitingEvents.TryTake(out pair, -1)) { ProcessWatcher(pair.Watchers, pair.WatchedEvent); } } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } catch (OperationCanceledException) { //ignored } catch (Exception t) { #if !NET_CORE LOG.Error("Caught unexpected throwable", t); #endif } } } #if !NET_CORE catch (ThreadInterruptedException e) { LOG.Error("Event thread exiting due to interruption", e); } #endif #if NET_CORE catch (Exception e) { } #endif #if !NET_CORE LOG.Info("EventThread shut down"); #endif }
public void QueueEvent(WatchedEvent @event) { if (@event.Type == EventType.None && sessionState == @event.State) { return; } if (waitingEvents.IsAddingCompleted) { throw new InvalidOperationException("consumer has been disposed"); } sessionState = @event.State; // materialize the watchers based on the event var pair = new ClientConnection.WatcherSetEventPair(conn.watcher.Materialize(@event.State, @event.Type, @event.Path), @event); // queue the pair (watch set & event) for later processing waitingEvents.Add(pair); }
public void QueueEvent(WatchedEvent @event) { if (@event.Type == EventType.None && sessionState == @event.State) return; sessionState = @event.State; // materialize the watchers based on the event var pair = new ClientConnection.WatcherSetEventPair(conn.watcher.Materialize(@event.State, @event.Type,@event.Path), @event); // queue the pair (watch set & event) for later processing AppendToQueue(pair); }
public void QueueEvent(WatchedEvent @event) { if (@event.Type == EventType.None && sessionState == @event.State) return; if (waitingEvents.IsAddingCompleted) throw new InvalidOperationException("consumer has been disposed"); sessionState = @event.State; // materialize the watchers based on the event var pair = new ClientConnection.WatcherSetEventPair(conn.watcher.Materialize(@event.State, @event.Type,@event.Path), @event); // queue the pair (watch set & event) for later processing waitingEvents.Add(pair); }