Does EnableCollectionSynchronization also require locking use of the ICollectionView?

I am familiar with BindingOperations.EnableCollectionSynchronization to make WPF participate in locking access to an ObservableCollection for use on multiple threads.

But does this place the same restriction on my use of a CollectionViewSource.View that uses that ObservableCollection as its source? Or does the view contain its own internal list?

For example, consider the following simplified view-model (which I admit I have not compiled) with a protected list of shapes that is publicly exposed from a CollectionViewSource view. As long as I protect every use of the _shapes collection with the _lock object, I should be fine and WPF will like me.

But should I be locking the same _lock object in the DoesViewContainShape function?

public class MeasureVm
{
    public MeasureVm()
    {
        BindingOperations.EnableCollectionSynchronization(_shapes, _lock);  
        _cvsShapes = new CollectionViewSource() { Source = _shapes, Filter = FilterShapes };
    }

    // WPF Binds to this

    public ICollectionView Shapes => _cvsShapes.View;

    private  bool FilterShapes(object obj)
    {
         // Eventually some arbitrary code to filter out shapes
         return true.
    }
    public void AddShape(shape)
    {
        // Any use of _shapes requires locking.

        lock(_lock)
            _shapes.Add(shape);
    }

    public bool DoesViewContainShape(Shape shape)
    {
        // SHOULD I LOCK HERE?
        return _cvsShapes.View.Contains(shape);
    }

    private ObservableCollection<Shape> _shapes = new();
    private CollectionViewSource _cvsShapes;
    private object _lock                        = new();

}

2

You are confusing the ICollectionView interface (https://learn.microsoft.com/ru-ru/dotnet/api/system.componentmodel.icollectionview?view=windowsdesktop-8.0) with its implementation, the CollectionView class (https://learn.microsoft.com/en-us/dotnet/api/system.windows.data.collectionview?view=windowsdesktop-8.0).
The ICollectionView interface does not impose restrictions on multithreading.
The CollectionView class is derived from DispatcherObject, which itself ensures its thread safety, but also makes it single-threaded (in the thread that created it).

P.S.

I was simply noting that the only thing that I get from CollectionViewSource.View is the interface. Is that always implemented by an instance of the CollectionView class? Is that guaranteed?

In default implementations, the CollectionViewSource.View property will always return a class derived from CollectionView. But if desired, you can replace it with your own custom implementation of ICollectionView, which will not be derived from CollectionView. Although this is not excluded, but in all my practice, I have not encountered such a solution.
For “replacement”, it is necessary that the source implements the ICollectionViewFactory Interface.

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật