DataSet Row Locking

  • Thread starter Thread starter Randy L.
  • Start date Start date
R

Randy L.

We are using a typed dataset in a singleton type scenario that is not bound
to a database. With multiple clients modifying the dataset we have
implemented a simple DataRow locking approach. The goal here is to insure
thread safety on tranactions in the dataset.

For example:

if( CurrentDataRow.RowState == DataRowState.Unchanged)
{
CurrentDataRow.Delete();
CurrentDataRow.AcceptChanges();
}

Is there a better appraoch to this? Is this enough info to get the gist of
the problem?

Thanks,
Randy L.
 
Hi Randy,

Are you using CurrentDataRow.RowState == DataRowState.Unchanged to ensure
the row is not being operated by other threads? In my opinion, this is not
reliable, because after the the if statement, this row still might be
changed. In this case, I suggest you try to use lock statement in C# to
lock the whole DataRow object.

lock(CurrentDataRow)
{
}

Please check the following links for more information:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html
/vclrfcsharpspec_8_12.asp

http://msdn2.microsoft.com/en-us/library/c5kehkcz.aspx

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top