Private networkAvailableEventHandler As NetworkAvailableEventHandler = AddressOf NetworkConnectionChanged

 Private Sub NetworkConnectionChanged(sender As Object, e As NetworkAvailableEventArgs)
        If Not disposed Then
        End If
 End Sub

 Dim disposed As Boolean = False
    Public Overloads Sub Dispose() Implements IDisposable.Dispose
    End Sub

    Protected Overridable Overloads Sub Dispose(disposing As Boolean)
        If disposed = False Then
            If disposing Then
                RemoveHandler My.Computer.Network.NetworkAvailabilityChanged, networkAvailableEventHandler
                networkAvailableEventHandler = Nothing
                disposed = True
            End If
        End If
    End Sub

    Protected Overrides Sub Finalize()
    End Sub

I have something close to above, my problem is, even after disposing the whole object the EventHandler invoke the NetworkConnectionChanged method even after removing the address.

any clues?

Recommended Answers


You can find an example about Removehandler, Here

Jump to Post

All 3 Replies


You can find an example about Removehandler, Here

That post didnt help but thanks!

Here's how I'm handling things:

AddHandler Button1.Click, AddressOf NetworkConnectionChanged

Button1.Click could be remove with your event. And btw, AddHandler sometime doesn't work with Private Sub, use Sub instead might be safer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.