NetworkAvailabilityChanged

styxke

Member
Joined
May 18, 2006
Messages
16
Programming Experience
5-10
Hi all,

I have this code:

VB.NET:
AddHandler System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged, AddressOf NetAvailabiltyChanged

  Public Sub NetAvailabiltyChanged(ByVal sender As Object, ByVal e As Net.NetworkInformation.NetworkAvailabilityEventArgs)
    If Not e.IsAvailable Then
      MessageBox.Show("Network not available", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Else
      MessageBox.Show("Network available", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End If
  End Sub
But the event never fires ...
I searched google and found exactly the same thing that I am doing, but apparently I must do something wrong.

Any suggestions would be appreciated.

Thanks in advance.
 
Last edited:
It doesn't look like you have an instance of the delegate that points to that event.

VB.NET:
 [/COLOR]
[COLOR=black][COLOR=blue]Dim[/COLOR] handler [COLOR=blue]As[/COLOR] NetworkAvailabilityChangedEventHandler

[COLOR=blue]AddHandler[/COLOR] NetworkChange.NetworkAvailabilityChanged, handler
[/COLOR]
[COLOR=black]

This info is from MSDN and can be found here
 
My code in fact works but after some investigation VMWare was the guilty one. It keeps a couple of network interfaces open and the event never fires ... so after uninstalling VMWare, it works perfectly !
 
Back
Top