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

Events Question

2 REPLIES 2
Reply
Message 1 of 3
Amremad
271 Views, 2 Replies

Events Question

What's is deferent between the next two code

    Private Shared WithEvents docEvents As DocumentCollection
    Private Shared Sub docEvents_DocumentDestroyed(sender As Object, e As DocumentDestroyedEventArgs) Handles docEvents.DocumentDestroyed
        MsgBox(e.FileName & " docEvents_DocumentDestroyed")
    End Sub

    <CommandMethod("StartEventHandling")> _
    Public Sub Asdkcmd()
        docEvents = Application.DocumentManager
    End Sub

 and

Private Shared docDestroyedEvent As DocumentDestroyedEventHandler
    Public Shared Sub OnDocumentDestroyed(ByVal sender As Object, ByVal e As DocumentDestroyedEventArgs)
        MsgBox(e.FileName & " OnDocumentDestroyed")
    End Sub

    <CommandMethod("StartEventHandling")> _
    Public Sub Asdkcmd()
        Dim docs As DocumentCollection = Application.DocumentManager
        If docDestroyedEvent Is Nothing Then
            docDestroyedEvent = New DocumentDestroyedEventHandler(AddressOf OnDocumentDestroyed)
            AddHandler docs.DocumentDestroyed, docDestroyedEvent
        End If
    End Sub

 

and what's the best for use

2 REPLIES 2
Message 2 of 3
Amremad
in reply to: Amremad

?

Message 3 of 3
jeff
in reply to: Amremad

Have you looked at documentation for WithEvents?

http://msdn.microsoft.com/en-us/library/aty3352y(v=vs.100).aspx

You can also find your answers @ TheSwamp

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