Thread safe DataSet

  • Thread starter Thread starter jrad
  • Start date Start date
J

jrad

I have a dataset that contains multiple datatables.
I looked in the online help for dataset and it in the section on
thread safety, it states "All write operations should be
synchronized".

When committing changes to the database, we call:

TableAdapter.Update(DataSet.Table1);
DataSet.Table1.AcceptChanges();


Should we put a lock around both lines, or just the AcceptChanges()?

Thanks,
JR
 
I don't know either, but is there any perceivable downside to putting the
lock around both?
 
I don't know either, but is there any perceivable downside to putting the
lock around both?

I don't think there is a downside and was planning on putting a lock
around both.
I just wanted to get a better understanding of what was considered to
be a "write" operation so that I could make sure all write operations
are synchronized.

Thanks,
JR
 
I guess either could be considered a "write" operation since even Update
"writes" to memory that might be accessed by another thread if the DataSet
is shared across threads.
 
Back
Top