コード例 #1
0
 private void UpdateSnapshot()
 {
     if (_newSnapshotRequired)
     {
         _snapshotLock.TryEnterWriteLock(Timeout.Infinite);
         if (_newSnapshotRequired)
         {
             _baseSnapshot        = new ImmutableCollectionImpl <T>(WriteCollection);
             _newSnapshotRequired = false;
         }
         _snapshotLock.ExitWriteLock();
     }
 }
コード例 #2
0
        protected ConcurrentCollection(IEnumerable <T> Items)
        {
            _subscribers = new Dictionary <int, IObserver <NotifyCollectionChangedEventArgs> >();

            WriteCollection = new ObservableCollection <T>(Items);
            _baseSnapshot   = new ImmutableCollectionImpl <T>(Items);

            ViewModel = new ConcurrentCollectionViewModel <T>(this);

            WriteCollection.CollectionChanged += HandleBaseCollectionChanged;

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