Author Topic: Why I can't remove the handler??  (Read 1543 times)

0 Members and 1 Guest are viewing this topic.

guohq

  • Newt
  • Posts: 84
Why I can't remove the handler??
« on: December 16, 2010, 05:01:45 AM »
''autocad 2008

Public Class Class1
    Dim db As Autodesk.AutoCAD.DatabaseServices.Database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase

    Sub delent(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectErasedEventArgs)
        MsgBox("del")
    End Sub

    <Autodesk.AutoCAD.Runtime.CommandMethod("d1")> _
    Sub aa()
        AddHandler db.ObjectErased, AddressOf delent

    End Sub

    <Autodesk.AutoCAD.Runtime.CommandMethod("d2")> _
    Sub bb()
        RemoveHandler db.ObjectErased, AddressOf delent

    End Sub
End Class

bikelink

  • Guest
Re: Why I can't remove the handler??
« Reply #1 on: December 17, 2010, 12:42:54 AM »
Does the document  exists when You try to deregister the event ?
what kind of error is showed ?
« Last Edit: December 17, 2010, 12:46:25 AM by bikelink »

guohq

  • Newt
  • Posts: 84
Re: Why I can't remove the handler??
« Reply #2 on: December 17, 2010, 01:01:00 AM »
there is no error when I deregister the event .

bikelink

  • Guest
Re: Why I can't remove the handler??
« Reply #3 on: December 17, 2010, 03:26:12 AM »
how many times do you call register ? just one ?
Maybe you have registered many times the delegate..and just one deregistration isn't enough.


try to post all your code..  or is that all?