Thread safe DataSet

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
 
G

Ginny Caughey

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

jrad

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
 
G

Ginny Caughey

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top