Updating DataTable best practice question

  • Thread starter Thread starter Jon Pope
  • Start date Start date
J

Jon Pope

Currently, I'm investigating various architecture designs which involve
maintaining a DataTable object within a background thread. I have various
grids which will feed from that DataTable via DataView objects. Thus the
layout is:

DataTable object (worker thread) -> DataView object (main thread) ->
GridControl (main thread)

The DataTable object is instantiated within the main thread, then supplied
to my worker thread class.

Currently, my background thread makes updates/inserts/deletes to that
DataTable, then via the DataViews, the grids are automagically updated to
show those changes. A vast majority of the time this works well. However,
occasionally I'll get the big red "X" on my grid control, which typically
means I'm doing something wrong threading-wise. Only the worker thread is
making modifications to the DataTable, while the main thread should just be
reading from it.

Is my basic design thread-friendly? Or is my design flawed?


Cheers, Jon
 
I don't think I am understanding what you are trying to solve here.

The UI (main thread) will interact with the data bound to it regaurdless of
the thread used to instantiate the data.

Once you are ready to work with the data, such as commit changes to the
persistant store, a secondary (background thread) may be used. When
invoking a method call on the background thread, you will passing
appropriate information (such as dataset.getchanges). Because you have now
disconnected the data on the UI thread from the background thread, you will
have to sync changes (dataset.merge, dataset.acceptchanges).

Think of a secondary thread as a process space not on your computer, only
better.
 
Back
Top