Solved

Is a DataSet threadsafe for merge and write?

Posted on 2007-03-31
6
727 Views
Last Modified: 2013-12-16
Visual Studio DotNet 2005:
The question is whether a DataSet is threadsafe for merge and write.
It is a bet and we just need the answer "yes" or "no".
Sorry, cannot participate you in the win of the bet, as we need a an unbiased answer.
0
Comment
Question by:tm
  • 3
  • 3
6 Comments
 
LVL 41

Expert Comment

by:graye
ID: 18829927
That's kinda a loaded question...   Are you talking about reads/writes to the in-memory represenation of the DataTables?   or are you talking about reads/writes to the underlying database.

Recall, it's the job of the underlying database (not ADO.Net) to ensure database integrity with concurrent writes.   Databases are free to use whatever record locking systems they need to make that happen.  

However, the read/writes to DataTables in the DataSet itself do not touch the underlying database... it just does it's thing with the in-memory represenation of the DataTables.
0
 

Author Comment

by:tm
ID: 18840045
The question does not address the underlying database, but the inimemory access to the DataTables in the DataSet. Whether these interactions are threadsafe for write and for merge.

Thanks - Thomas

0
 
LVL 41

Expert Comment

by:graye
ID: 18840142
Well, the documentation at http://msdn2.microsoft.com/en-us/library/system.data.dataset(VS.71).aspx

says...

Thread Safety
This type is safe for multithreaded read operations. You must synchronize any write operations

So, I'd consider that a definative anwer.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:tm
ID: 18840164
Obviously it means the it is save for read operation.
It may come to a linguistic interpretation for the write and merge operation:
Does that mean it is thread-safe or not?

Thanks - Thoams
0
 
LVL 41

Accepted Solution

by:
graye earned 125 total points
ID: 18840498
The documentation says that "write operations" are *not* thread safe...   So, in my mind that includes write and merge operations.

But, on the other hand, what do you mean by "write and merge".  

        Are you referring to a DataTable.Row changes (insert, delete, modify) as a "write"?
        Are you referring to a DataSet.Merge operation where changes to one DataTable are reflected in another as "merge"?

If so, then those are both "write operations" because they perform actions that trigger RowChange events.  (that's a pretty good definition of "write" in this context)
0
 

Author Comment

by:tm
ID: 18840708
Graye, great explanation - thanks very much!
And beside helping me better understand it, it makes me win a bottle of wine. If once you are in North Carolina, I'd like to share it with you.
Thanks.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question