Custom DataFactory, Threaded calls to GetDataAccessors

Grids for WPF Forum

Posted 15 years ago by jeff jarrell
Avatar
I have a CustomDataFactory that I am using .SelectedObject(s) with. I understand the notion of DataFactoryOptions.ParentAccessor and have GetDataAccessors return null when the ParentAccessor is not null (my properties don't have properties).

I have a context where I am using I am using a SelectedItems collection of a DataGrid (Exceed). I push the update into the PropertyGrid.SelectedObject(s) when I get a NotifyCollectionChanged event.

As I multi-select items in the grid it works ok for a couple of items. Then past a certain selection count of items, I see redundant calls to the GetDataAccessors. It's on different threads because my GetDataAccessors isn't built to be threadsafe :).

The IEnumerable I was setting into PropertyGrid.SelectedObjects was an ObservableList and when I changed it to NOT be observable this seem to fix it up.

1)Does having .SelectedObjects set to an Observable have an impact?

By not using an Observable things work so long as things are moving slowly. Obviously, working off NotifyCollectionChange pushes too many updates into the PropertyGrid (which it then trys to spin up threads, which then blows up my non-thread safe Factory.

I can queue this up and control the update being pushed to the .SelectedObjects.

2) I do see the PropertyGrid.IsAsync property. What am I giving up if I turn this off?

3) In this DataGrid context where we are multi-selecting objects to push into the property grid I can see the need and the advantage of multiple threads, but how does the DataFactory distinguish one call from another (so that the objects can be distributed to different threads for Accessor building).

Thanks for any advice.
jeff

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Jeff,

1. The SelectedObjects works much like the ItemsSource of a ListBox. If the assigned collection implements INotifyCollectionChanged, then the PropertyGrid will attach itself to the CollectionChanged event. When the collection rasies this event, the PropertyGrid will refresh it's items.

You can also optionally, call BeginUpdate and EndUpdate on the PropertyGrid to batch changes that affect the items. For example, if you change IsCategorized and then change the SelectedObject, then that would result in two updates. You can batch those into a single update by wrapping the code with BeginUpdate/EndUpdate.

2. This property controls whether the PropertyGrid will execute calls into the DataFactory on a separate thread. So if your DataFactory is not thread-safe then this should be set to false.

3. I'm not sure I fully understand this question. Each call to the DataFactory is performed when needed and is completely independent of other calls. Therefore, the PropertyGrid can retrieve properties for several objects in parallel.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.