Solved

Is a DataSet threadsafe for merge and write?

Posted on 2007-03-31
6
715 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
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.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now