static void Main(string[] args) { var list = new ObservableCollection<string> { "hello", "world" }; collection = new ThrottledObservableList<string>(list); //var seed = new AccumulatorType(); var rawEventSource = Observable.FromEventPattern<NotifyCollectionChangedEventArgs>(collection, "CollectionChanged") .Select(a => a.EventArgs); rawEventSource.Subscribe(Publish); Observable.FromEventPattern<PropertyChangedEventArgs>(collection, "PropertyChanged") .Select(a => a.EventArgs) .Where(a => a.PropertyName == "Count") .Subscribe(CountChanged); ThreadPool.QueueUserWorkItem((s) => { foreach (var i in Enumerable.Range(1, 10)) { GenerateEvents(collection); //GenerateRemoveEvents(collection); System.Threading.Thread.Sleep(105); } }); Console.ReadLine(); }
private static void GenerateRemoveEvents(ThrottledObservableList<string> collection) { for (int i = collection.Count - 1; i >= 0; i--) { collection.RemoveAt(i); } }