Solved

Is a DataSet threadsafe for merge and write?

Posted on 2007-03-31
6
742 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

685 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