Must create DependencySource on same Thread as DependencyObject

后端 未结 3 1078
甜味超标
甜味超标 2021-01-04 14:10

I have an application written in wpf, which downloads some webpages, parses html code and saves some values.

class ListOfItems
{    
    public List

        
3条回答
  •  感动是毒
    2021-01-04 14:29

    The SolidColorBrush is a Freezable which is a derived DispatcherObject. DispatcherObjects have thread affinity - i.e it can only be used/interacted with on the thread on which it was created. Freezables however do offer the ability to freeze an instance. This will prevent any further changes to the object but it will also release the thread affinity. So you can either change it so that your property is not storing a DependencyObject like SolidColorBrush and instead just store the Color. Or you can freeze the SolidColorBrush that you are creating using the Freeze method.

提交回复
热议问题