Private networkAvailableEventHandler As NetworkAvailableEventHandler = AddressOf NetworkConnectionChanged

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

 Dim disposed As Boolean = False
    Public Overloads Sub Dispose() Implements IDisposable.Dispose
        Dispose(True)
        MyBase.Dispose()
        GC.SuppressFinalize(Me)
    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()
        Dispose(False)
    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?

Hi,

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 meeting, networking, learning, and sharing knowledge.