samedi 19 septembre 2015

Transactions implementation

In the project (UI + service) we use transactions in the sense cancelling tasks, cancelling bunch of tasks and so on. It doesn't have anything to do with SQL transactions. I would like to refactor spaghetti code and implement transaction pool which could help to manage transactions out of the box. Could you please share some insights on patterns, examples which could help to tackle this task. Where I could look at? Example:

Action action;
string name = "mytransaction";
using (var tran = Transaction.CreateTransactionScope(name))
{
    try
    {
       trans.Execute(action);
    }
    catch(Exception)
    {
      tran.Rollback();
    }
}

somewhere in UI:

Transaction.CancelScope(name)

Aucun commentaire:

Enregistrer un commentaire