예제 #1
0
 private void UpdateSnapshot()
 {
     if (_newSnapshotRequired)
     {
         _snapshotLock.TryEnterWriteLock(Timeout.Infinite);
         if (_newSnapshotRequired)
         {
             _baseSnapshot        = new ImmutableCollection <T>(_baseCollection);
             _newSnapshotRequired = false;
         }
         _snapshotLock.ExitWriteLock();
     }
 }
예제 #2
0
        protected ConcurrentObservableBase(IEnumerable <T> enumerable)
        {
            _subscribers = new Dictionary <int, IObserver <NotifyCollectionChangedEventArgs> >();

            _baseCollection = new ObservableCollection <T>(enumerable);
            _baseSnapshot   = new ImmutableCollection <T>(enumerable);

            _viewModel = new ObservableCollectionViewModel <T>(this);

            _baseCollection.CollectionChanged += HandleBaseCollectionChanged;

            _viewModel.CollectionChanged += (sender, e) =>
            {
                CollectionChanged?.Invoke(sender, e);
            };
        }