How to Write Atomic Transactions in .NET
page 1 of 7
Published: 18 Sep 2006
Abstract
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.
by Keyvan Nayyeri
Feedback
Average Rating: 
Views (Total / Last 10 Days): 37531/ 68

Introduction

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.

This scenario is common for computer systems and you can see it many times in memory management, IO operations and database interactions.

Atomic transactions are a way to avoid this problem.  They simply lock on a transaction and do not allow any other transaction to interact with the resource.  If anything fails during the Atomic transaction, everything will return to the state before the transaction started.

In this article I give a step by step sample to write an Atomic transaction in .NET and test it to see it in action.  In this article I created a simple accounting system and then in an Atomic transaction I add values to an account and a place to throw exceptions for some arguments to see what would happen if something goes wrong in an Atomic transaction.


View Entire Article

User Comments

Title: ASAS   
Name: ASAS
Date: 2012-08-01 7:53:47 AM
Comment:
asd
Title: Very Gud   
Name: Soby
Date: 2007-06-09 7:26:03 AM
Comment:
This is very Help for me

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 4:18:05 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search