Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Monday, September 25, 2006

How to Write Atomic Transactions in .NET

Atomic transactions are the base part of ACID theory. Using this kind of transaction you can make sure your transaction will not cause any problem for the system if something goes wrong or if multiple requests are sent for the same resource or data. In this article Keyvan shows the simple process to write these transactions in .NET.

Article Contents:

Atomicity, Consistency, Isolation and Durability (ACID) theory is familiar to many programmers.  Those who work on Operating System design use it almost everday.

The most important aspect of ACID is an Atomic transaction.  What is an Atomic transaction?  The best way to describe it is a famous example: a bank accounting system.

Consider that bank A and bank B want to interact with someone's account at the same time.   Both banks want to withdraw from the account and the account has $10.00 in it.  If bank A takes $7.00 and at the same time bank B tries to get $5.00, what will happen?  When they start the transaction each bank believes there is $10.00 available in the account.  When one of them finishes the other one will find there is not enough money to finish the transaction.

To finish preparing my database, I added a sample account to my table.

Figure 1

Post a Comment