Actually, just doing lock in one place in a DataTable or DataRow does virtually nothing. An important aspect to remember when using Monitor locks (which is a lock block) is that locking an object does nothing for it; One of the reasons some proponents use dedicated blocking objects rather than blocking the resource itself is because it makes you realize that you need to lock (and on the same object) whenever you deal with the resource.
This means that it is best to lock the entire DataTable , since the data store itself ( DataRow objects internally contain only an offset in the DataTable relative to where to retrieve data), because of this, even if you synchronize access to individual rows, updating two different rows at the same time will cause you to update the same storage engine in an unsynchronized manner.
There is a conflict between viewing internal types as a βblack boxβ and blocking only what you need (which in this case will lead to an erroneous termination of only line blocking) and trying to get an idea of ββthe internal type workings and relying on implementation details that may to change.
The result is that right now you should lock the entire DataTable to avoid updating the internal storage in an unsynchronized way .
Adam robinson
source share