ECO atomic operations
I’ve just created a simple class which I thought I’d share. Account1.Balance += 10 ; Account2.Balance -= 10 ; In this case we might expect the second line to throw an exception if the adjustment is not permitted, but the first line has already executed. Obviously this isn’t a problem because we simply wouldn’t update the database, but sometimes you want an operation to occur in memory as an atomic operation; like this using (var atomicOperation = new AtomicOperation(EcoSpace)) { Account1.Balance += 10 ; Account2.Balance -= 10 ; atomicOperation.Commit(); } And so that is exactly what I wrote. The class uses the UndoService to create/merge/remove undo blocks so it is even possible to nest atomic operations. public class AtomicOperation { readonly IEcoServiceProvider EcoServiceProvider; readonly IUndoService UndoService; readonly IUnitOfWorkValidator UnitOfWorkValidator; bool IsActive; string UndoBlockName; ...