Where to Lock when updating a DataTable

  • Thread starter Thread starter paul
  • Start date Start date
P

paul

Hi,

I have an C# app which uses a Dataset which contains multiple
DataTables as an in memory database. (Currently the dataset is not
connected to a database.)

The app is multi threaded and adds/update rows in the various tables.
Currently I lock the Dataset on each modification - but am I locking at
the right (most efficent) level? Could I just lock at the DataTable or
even just the row? or can I do without locks?

TIA

swin
 
Hi Paul,

I would lock at DataTable level as row update might affect internals (index,
etc.).
Note that I am not 100% sure whether this is enough.
 
OK thanks.

Paul
Hi Paul,

I would lock at DataTable level as row update might affect internals (index,
etc.).
Note that I am not 100% sure whether this is enough.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,

I have an C# app which uses a Dataset which contains multiple
DataTables as an in memory database. (Currently the dataset is not
connected to a database.)

The app is multi threaded and adds/update rows in the various tables.
Currently I lock the Dataset on each modification - but am I locking at
the right (most efficent) level? Could I just lock at the DataTable or
even just the row? or can I do without locks?

TIA

swin
 
And you might also consider using ReaderWriterLock as your locking mechanism
in case you have many reads and few writes.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

OK thanks.

Paul
Hi Paul,

I would lock at DataTable level as row update might affect internals
(index,
etc.).
Note that I am not 100% sure whether this is enough.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Hi,

I have an C# app which uses a Dataset which contains multiple
DataTables as an in memory database. (Currently the dataset is not
connected to a database.)

The app is multi threaded and adds/update rows in the various tables.
Currently I lock the Dataset on each modification - but am I locking at
the right (most efficent) level? Could I just lock at the DataTable or
even just the row? or can I do without locks?

TIA

swin
 
Back
Top