Question about using Transactions in threaded loop code

Posts   
 
    
ottoacosta
User
Posts: 34
Joined: 16-Aug-2007
# Posted on: 09-Apr-2009 14:26:48   

Guys,

I have a very simple question for you. In the following code scenario

while(true) { Transaction tran = new Transaction (System.Data.IsolationLevel.ReadCommitted, "PickManager - CreateOrder");

        try
        {
            .....
           tran.commit();
         }
         catch(Exception ex)
         {
            tran.Rollback();
         }
        finally
        {
          trans.Dispose();
        }

      Thread.Sleep(1000);

}

Is it more efficient to create a new transaction object on every thread iteration (like shown here) or to create the transaction before the start of the loop and re-use it?

  • LLBLGen Version 2.6
  • .NET 3.5
  • Oracle 10g
  • ODP.NET 10g 2.102.2.20.

Thanks.