Optimistic Versus Pessimistic Concurrency

An old adage says: “If I can get something but it is tainted, it does me no good to get it in the first place.”

Well, that's what managing concurrency is all about—making sure you can update data along with the guarantee that what you are updating hasn't changed because someone else came along and updated it right out from under you. Let's first look at optimistic concurrency because it is the preferred approach in most .NET programming.

Optimistic concurrency allows for multiple users to read the same data row at the same time without having to lock it (for update). Then any one of the users can change (update) the data values at this point. An optimistic concurrency violation will occur when a user ...

Get Sams Teach Yourself ADO.NET in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.