Re: Thread safety of DataTable class - Filling on background thread OK?



It sounds weird. It shouldn't take that much time. Are you sure? How many
records we are talking about?

About 150,000 records. The private bytes used by my app go up
about 100 MB because of the Fill. Is a >10 (actually more like 15)
second Fill reasonable for that many records?

Maybe in-memory DataTables and DataSets aren't normally used
with that many records?

That's huge.
The real question is the design of your application. Do you really need that
much records at client side? Can be done differently?

Yes it probably can and should be done differently.
One advantage of pulling it all into memory is that once it's there
it's fast to iterate over all the records to compute some statistics,
but there are probably other ways I can do that like queries.

I also currently bind all 150,000 records to a grid, which
apparently is a somewhat naive design. That bind to the grid
also takes an additional 15 seconds, during which the GUI thread
is again blocked and unresponsive. Apparently there is also no
way to do the bind asynchronously and no simple stock way to
get some kind of automatic paging of individual screenfuls of
rows. I guess the "solution" is to just load and bind less.

It has been said before: SQL's SELECT statement has a WHERE
clause for a reason :).

I noticed the method BindingSource . SuspendBinding. Is that ever
used for that purpose?

I guessed so, but a while ago I tested and I recall that it wasn't working
as expected.
Not 100% sure on this, I guess I have to test a bit more.

Or when you say "unbind the controls" that
would be something like temporarily setting
BindingSource . DataSource to null or typeof( MyDataSetType )
or something like that?

Yes, that's why I meant - disconnecting datasource - that will always work.

BTW: When I tried "unbinding" the controls by setting
BindingSource.DataSource to null or typeof( MyDataSetType ) I got
"Cannot bind to the property or column..." exceptions. What did work
was to set DataSource to point at an empty instance of my typed
DataSet.

Thanks,
Alan
.