.NET

Reply
Mentor
Amremad
Posts: 212
Registered: ‎08-24-2010
Message 1 of 3 (135 Views)

Events Question

135 Views, 2 Replies
04-09-2013 03:59 AM

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

Mentor
Amremad
Posts: 212
Registered: ‎08-24-2010
Message 2 of 3 (92 Views)

Re: Events Question

04-10-2013 11:49 AM in reply to: Amremad

?

Valued Mentor
jeff
Posts: 322
Registered: ‎05-12-2009
Message 3 of 3 (84 Views)

Re: Events Question

04-10-2013 01:51 PM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community