Can we implement Transaction on C# objects?

What you are asking is called Software Transactional Memory. Since this is currently an open area of research and there is no native C# language support at the moment, you might be better off using the existing synchronization options for C#, such as the lock keyword, monitors, wait handles, etc.

If you really need advanced transactional features, there are a lot of library implementations, see this list in Wikipedia for some examples:

  • https://en.wikipedia.org/wiki/Software_transactional_memory#C.23

You may be interested by Software Transactional Memory. It exists one implementation in the .NET world, named STM.NET.

Software Transactional Memory (STM.NET) is a mechanism for efficient isolation of shared state. The programmer demarcates a region of code as operating within a transaction that is "atomic" and "isolated" from other transacted code running concurrently.

Here is the blog of the Microsoft STM.NET team : http://blogs.msdn.com/stmteam/

Tags:

C#

.Net