Kean Walmsley

July 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Twitter Updates

    follow me on Twitter



    « Reflecting on AutoCAD .NET | Main | Adding to the AutoCAD pickfirst set with .NET »

    January 26, 2007

    TrackBack

    TrackBack URL for this entry:
    http://www.typepad.com/services/trackback/6a00d83452464869e200d834ddc70153ef

    Listed below are links to weblogs that reference One for the bit-twiddlers:

    Comments

    well, reflector output is actually html:)

    Thanks, zproxy - I did realise that. :-)

    Even so, I was still impressed that the results came across so cleanly.

    Dear Kean,

    I hope this one's not fully offtopic :-)Try...Catch...Finally block utilizes different Transaction approach on it's Abort method. As far as I can see, calling Transaction.Abort is not equal to calling Transaction.Dispose (invoked via IDisposable within Using block). Here's what Reflector says about the difference:

    ----------------------------------------------
    Protected Overrides Sub Dispose( ByVal disposing As Boolean)
    Me.CheckTopTransaction
    Dim managerPtr1 As AcDbTransactionManager* = .AcDbImpTransaction.transactionManager(DirectCast(Me.GetImpObj, AcDbImpTransaction* ModOpt(IsConstModifier) ModOpt(IsConstModifier)))
    Interop.Check(*DirectCast(managerPtr1, Integer*)(32)(managerPtr1))
    End Sub

    ----------------------------------------------
    Public Overridable Sub Abort()
    Me.CheckTopTransaction
    Dim managerPtr1 As AcDbTransactionManager* = .AcDbImpTransaction.transactionManager(DirectCast(Me.GetImpObj, AcDbImpTransaction* ModOpt(IsConstModifier) ModOpt(IsConstModifier)))
    Interop.Check(*DirectCast(managerPtr1, Integer*)(32)(managerPtr1))
    MyBase.AutoDelete = False <<<<< AHA!
    End Sub

    ----------------------------------------------
    AutoDelete property, inherited from DisposableWrapper, has interesting setter part:

    _
    Property AutoDelete As Boolean
    Public Get
    Return Me.m_bAutoDelete
    End Get
    Friend Set( ByVal value As Boolean)
    If (Me.m_bAutoDelete <> value) Then
    Dim ptr1 As IntPtr = Me.m_imp
    Me.Detach
    Me.Attach(ptr1, value)
    GC.KeepAlive(Me)
    End If
    End Set
    End Property

    ----------------------------------------------
    So, if there is a significant difference when calling Transaction.Abort before Transaction.Dispose, then there's no Try/Using paradigm at all :-)

    Hi Maksim,

    I don't quite understand your reasoning. Abort kills the underlying unmanaged transaction so it sets the AutoDelete flag to false to avoid a double delete if Dispose is called. (This also removes the object from the finalizer queue.)

    Can you give me more details what you believe is a problem?

    Thanks,
    albert

    Hi Albert,

    Thanks for the clarification. I recently had a discussion with my colleagues on IDisposable implementation of the Transaction object. We were actually trying to figure out whether it's safe (in a sense of in-transaction instantiated DBROs) to Dispose running Transaction regardless of it's commited/aborted state.

    Regards,
    Maksim Sestic


    Verify your Comment

    Previewing your Comment

    This is only a preview. Your comment has not yet been posted.

    Working...
    Your comment could not be posted. Error type:
    Your comment has been posted. Post another comment

    The letters and numbers you entered did not match the image. Please try again.

    As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

    Having trouble reading this image? View an alternate.

    Working...

    Post a comment

    Feed & Share

    Search