开发者

DataTable internals and multithreaded usage

开发者 https://www.devze.com 2023-01-24 04:11 出处:网络
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, updat

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 DataTables are not really know for being all that useful in parallelized algorithms. The problem with DataTables is that DataRows 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 DataRows are safe for multiple readers (as long as there are no writers) so all is not lost.

0

精彩评论

暂无评论...
验证码 换一张
取 消