I would like to know if there is great book or website that discusses in great detail how to use DataTable in a multithreaded way. It should discusses in great detail how it behave upon add, get, update and deletion of rows. It should also discuss the proper way of using locks, acceptchanges and开发者_如何转开发 other important details.
DataTables aren't special: just reading from a DataTable
instance is thread-safe (as it says in the documentation), but if you change any aspect of an instance you have to make sure that you synchronize access to it.
Instead of looking for something specific to multithreading data tables, you should read about threading in general. For that, you can't go wrong with Joseph Albahari's Threading in C#.
(Having said that, take a look at this discussion thread on a related topic.)
I do not think you are going to find a whole of lot of information on the topic. That is a pretty narrow topic for a book and DataTable
s are not really know for being all that useful in parallelized algorithms. The problem with DataTable
s is that DataRow
s are married to them in obscure ways. For example, changing a column value in a DataRow
that is part of a primary key will update the parent DataTable
's index. This makes it a lot harder to get meaningful parallel throughput because you pretty much have to lock access to everything when making any kind of changes. However, DataTable
's and DataRow
s are safe for multiple readers (as long as there are no writers) so all is not lost.
精彩评论