devexpress data synchronization (multiple gui threads, one data thread)

C

CBanu [IXIA]

Hello,

I am trying to get the following scenario to work: multiple gui
threads, containing various controls bound to the same data source
(BindingList<T>, with an exposed ICollection.SyncRoot), and a data
thread that performs the updates on the data. The problem is that I
cannot get the devexpress controls (GridControl and TreeList) to lock
on the provided SyncRoot. How can I achieve this? How can I have, at
the same time, data operations, and gui updates (using locking, the
updates should be postponed until the changes are performed). Any
ideas?

Thanks,
Cosmin
 
B

Brian Gideon

Hello,

I am trying to get the following scenario to work: multiple gui
threads, containing various controls bound to the same data source
(BindingList<T>, with an exposed ICollection.SyncRoot), and a data
thread that performs the updates on the data. The problem is that I
cannot get the devexpress controls (GridControl and TreeList) to lock
on the provided SyncRoot. How can I achieve this? How can I have, at
the same time, data operations, and gui updates (using locking, the
updates should be postponed until the changes are performed). Any
ideas?

Thanks,
Cosmin

First, I think it's odd that you have multiple UI threads. I'm not
saying that you shouldn't do that, but it's usefulness is quite rare.

Second, instead of trying to get UI controls to share a data structure
updated by another thread what I would do is deep copy the structure
and publish it to the UI threads by calling Control.Invoke from the
worker thread. That way you don't have to worry about explicit
locking or trying to get a control to always synchronize access to its
data source.

Brian
 
C

Chris Mullins [MVP]

We solved this problem by having two copies of the datastructures:
- Copy 1 is the "real" copy, and it gets updated from any number of threads.
- Copy 2 is the "Display" copy, and it's bound to the display controls.

When we do the Update/Merge/Rebind code, we can do this inside
a lock. This makes everything work well, and remain happy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top