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

Re: Where to Lock when updating a DataTable by Miha

Miha
Thu Jun 08 14:29:31 CDT 2006

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/

<paul@swindell.com> wrote in message
news:1149783863.387679.170350@f6g2000cwb.googlegroups.com...
> 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
>



Re: Where to Lock when updating a DataTable by paul

paul
Fri Jun 09 10:40:03 CDT 2006

OK thanks.

Paul

Miha Markic [MVP C#] wrote:

> 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/
>
> <paul@swindell.com> wrote in message
> news:1149783863.387679.170350@f6g2000cwb.googlegroups.com...
> > 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
> >


Re: Where to Lock when updating a DataTable by Miha

Miha
Fri Jun 09 15:33:04 CDT 2006

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/

<paul@swindell.com> wrote in message
news:1149867603.511603.66840@c74g2000cwc.googlegroups.com...
> OK thanks.
>
> Paul
>
> Miha Markic [MVP C#] wrote:
>
>> 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/
>>
>> <paul@swindell.com> wrote in message
>> news:1149783863.387679.170350@f6g2000cwb.googlegroups.com...
>> > 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
>> >
>