/// <summary> /// Processes the specified event. /// </summary> /// <param name="evt">The event to process</param> public void Process(WatchedEvent evt) { if (evt == null) { throw new ArgumentNullException(nameof(evt)); } lock (this) { this.handler.instrumentation.WatcherNotificationReceived(evt.EventType); this.eventQueue.Enqueue(evt); } Task.Run(this.DispatchEvent); }
private async Task DispatchEvent() { // Watcher notifications can be dispatched only after the // response for the request that installed the watcher is // processed. await this.readyToDispatch.Task; // Dispatch all events received so far in the order they were // received. lock (this) { while (this.eventQueue.Count > 0) { WatchedEvent evt = this.eventQueue.Dequeue(); RingMasterClientEventSource.Log.DispatchWatcherNotification(this.Id, evt.Path, (int)evt.EventType); this.watcher.Process(evt); } } }
/// <summary> /// Determines whether the specified <see cref="object" /> is equal to this instance. /// </summary> /// <param name="obj">The object to compare with the current object.</param> /// <returns><c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.</returns> public override bool Equals(object obj) { WatchedEvent other = obj as WatchedEvent; if (other == null) { return(false); } if (other.EventType != this.EventType) { return(false); } if (other.KeeperState != this.KeeperState) { return(false); } return(string.Equals(this.Path, other.Path)); }