I’ve developed a data adquisition subsystem as a DLL that captures data using its own thread and published the data using ObservableCollections. I’m facing several problems because the consumers of the events do expensive operations when they receive the ObservableCollection events and that’s making my engine to capture data slower than expected.
I plan to send the events in different threads to avoid this problems but I have several concerns:
public class ObservableCollection2
{
public void Add()
{
_internalObservableCollection.Add();
new Thread() { => Raise the event }
}
}
- Is this an already solved problem with a standard solution? Looks
like thread contention should be something relatively common. - Using Threads wouldn’t reduce badly the performance of the
application? - Using ThreadPool wouldn’t use all the available
Thread as it’s normal in the subsystem to send from 100 to 200
notifications per second?
Thanks for your thoughts.
There are several ideas about what can be done is this situation.
ObservableCollectionis quite a heavy class. I personally use it only in view models for binding from view, and in the model I resort to a self-made class containing a collection internally, and sending the needed events when needed. This way I have more control over what happens.