Fill DS in thread

  • Thread starter Thread starter wackyphill
  • Start date Start date
W

wackyphill

I have a long running query. I want the results in a DataGrid. I'd like
the grid and form to be responsive and fill up w/ rows as the result
set is read into a dataset that is the datasource of the grid.

Possible?
If so, how should the thread handle updating the grid's datasource and
have the grid reflect the changes w/o waiting till the thread finishes?

Any example would be greatly appreciated.
Thanks.
 
Hi,

In this case, you will most likely need to fill the DataSet manually from a
DataReader. Do this filling on the worker thread, and invoke an Update
method on the UI thread periodically by using Control.Invoke(). The Update
method will be re-binding the grid to the updated datasource. You must also
ensure that the datasource does not raise any events itself when it is being
modified on the worker thread. Otherwise, the grid might try to act upon
these events, and as soon as they are being raised on a non-UI thread, you
might get a nasty exception.
 
Would that cause the position in the Grid to be reset everytime the
datasource was updated? I'd like to avoid that.
 
Back
Top