Solved

Is a DataSet threadsafe for merge and write?

Posted on 2007-03-31
6
700 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:tm
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

19 Experts available now in Live!

Get 1:1 Help Now