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

Can you commit a Transaction within a Transaction?

1 REPLY 1
Reply
Message 1 of 2
VB_Autocad_guy
490 Views, 1 Reply

Can you commit a Transaction within a Transaction?

Transactions -- Can you commit a Transaction within a Transaction without any problems? 

 

I have one transaction that cycles through all objects in drawing..

I have another transaction that purges all purgable objects. 

 

Can I call the Purge Function if I've already started a transaction? 

What's the proper protocol here? Does that make sense? 

 

  'Purge Database
        Dim count As Integer = PurgeDatabase(DatabaseIn)
        Debug.Print("Number of Items Purged: " & count)

        'Level 1 Start(Transaction/Drawing Database)-----------------------------------------------
        Using myTrans As Transaction = DatabaseIn.TransactionManager.StartTransaction 'Read Drawing Database

            'Level 2 Block Table------------------------------------------------------------
            Dim myBT As BlockTable = DatabaseIn.BlockTableId.GetObject(OpenMode.ForRead) 'Read BlockTable
            
            'Loop Through All Objects
            For Each myObjID As ObjectId In myBT 'Changed this line of code from myModelSpace

 

Private Function PurgeDatabase(ByVal DB As Database) As Integer
        Debug.Assert(DB IsNot Nothing, "DB is nothing.")

        Dim idCount As Integer = 0

        Dim tr As Transaction = DB.TransactionManager.StartTransaction

        Using tr
            'Create the list of objects to "purge"

 

1 REPLY 1
Message 2 of 2

In general, yes. You can use nested transactions and commit the inner transaction first. If you abort any transaction it should also roll back the committed transactions nested within it. The full operation will only be committed once the topmost transaction has been commited.

Cheers,

Stephen Preston
Autodesk Developer Network

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