.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Abort and Dispose Transaction

2 REPLIES 2
Reply
Message 1 of 3
SRSDS
620 Views, 2 Replies

Abort and Dispose Transaction

This must be important but I don't understand the difference between the two.

 

 

 

 

2 REPLIES 2
Message 2 of 3
StephenPreston
in reply to: SRSDS

You shouldn't ever explicitly need to call Abort. If the Transaction is Disposed before you call Commit, then it calls Abort internally. Just make sure you Dispose of the Transaction immediately you've finished with it - never leave it to be garbage collected.

 

Cheers,

Stephen Preston
Autodesk Developer Network
Message 3 of 3
arcticad
in reply to: StephenPreston

        ' I would recommend that you wrap everything with using.
        ' This will ensure that it is automatically disposed of.

        Using db As Database = HostApplicationServices.WorkingDatabase()
            Using tr As Transaction = db.TransactionManager.StartTransaction
                Dim myDWG As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
                Using lock As DocumentLock = myDWG.LockDocument
                    ' ... Do stuff
                    tr.Commit()
                End Using
            End Using
        End Using

---------------------------



(defun botsbuildbots() (botsbuildbots))

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost