Hello,
I’m trying to understand some thread safety issues with DataSet.
- If I have one thread writing to DataTableA and another writing to DataTableB is that safe or do I have to prevent concurrent writes to different tables
- If I’m using remoting to transfer the DataSet which marshals by value I assume my remote instance of the DataSet can perform reads and writes concurrent with reads and writes with the local instance of the DataSet.
- Do I have to lock against local writes when I marshal the DataSet
Thanks,
Jeff

DataSet thread safety
shanlini
The DataSet and its connected objects can be used either by a single writer or multiple readers. Creating a DataView is considered a "read" operation.
1) You have to prevent concurrent writes to different DataTables that share the same DataSet. The primary concern is around expressions using relations between tables.
2) A remote instance can be used concurrently with the local instance.
3) While in the process of marshaling a DataSet you should protect against writes, but once complete the marshalled copy is a separate instance.
pvphuc
1. Not sure about this. My instinct is to say that there won't be any issue unless you have relationships between the two tables, in which case I'm not sure.
2. You are correct. Remoting a DataSet creates a completely separate copy that is not linked to the original in any way.
3. Not sure how this question is different than number 2. Can you clarify
CraftyFella
Thanks for the feedback. For #3 basically what I want to know is the act of marshalling considered a read or a write. If a write then I will have to protect against writing to the dataset while it is being marshalled. I'm thinking it should be a read, but then again I thought select should be a read to but apparently that writes to some internal cache so it is not safe.
Jeff
dsallow