Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a problem if I wrap my code in StartTransaction twice

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
soonhui
144 Views, 2 Replies

Is there a problem if I wrap my code in StartTransaction twice

Is there a problem if I write my code like this:

 

            using (ACADDocument.LockDocument())
            {
                using (var ts = ACADDatabase.TransactionManager.StartTransaction())
                {
                   using(ACADDocument.LockDocument())
                   {
                     using (var ts1 = ACADDatabase.TransactionManager.StartTransaction())
                     {
                      //do some action using ts1 transaction
                      ts1.Commit();
                      }
                    }
                   // do other action using ts transaction, which may or may not involve the objects in ts1 transactino
                    ts.Commit();

                }
            }

 

 

 

Setting aside the issue of whether this is the best way to do something, is it OK in all circumstances? Will it cause a problem if, for the ts transaction, I do something involving objects that I use in ts1? 

 

I got myself down this rabbit hole because of my zeal to wrap the code in functors and lambdas to simplify the code. But let's not argue whether this is good or not, just merely whether this will introduce unwanted behaviors or crashes. 

2 REPLIES 2
Message 2 of 3
essam-salah
in reply to: soonhui

hi @soonhui 

i think it's an Autocad question moving your post to Autocad .Net forum  is better.

Message 3 of 3
soonhui
in reply to: soonhui

I think this question can be deleted now; I've reasked at AutoCAD .Net forum.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report