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 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) { LOG.Error("Caught unexpected throwable", t); } } } catch (ThreadInterruptedException e) { LOG.Error("Event thread exiting due to interruption", e); } LOG.Info("EventThread shut down"); }