You can subscribe to the event associated with the IsAvailable property.
Subscribing the event you would receive notification every time the value of IsAvailable property changes.
You will not need to loop and consume CPU cycles.
You can write something like:
Private Sub DisplayAvailability(ByVal available As Boolean, ByVal notify As Boolean)
If available Then
Label1.Text = ("Internet Up")
If notify Then
MsgBox("Internet Back UP")
End If
Else
Label1.Text = ("Internet Down")
If notify Then
MsgBox("Internet DOWN")
End If
End If
End Sub
Private Sub MyComputerNetwork_NetworkAvailabilityChanged( _
ByVal sender As Object, _
ByVal e As Devices.NetworkAvailableEventArgs)
DisplayAvailability(e.IsNetworkAvailable, True)
End Sub
Private Sub Handle_NetworkAvailabilityChanged()
DisplayAvailability(My.Computer.Network.IsAvailable, False)
AddHandler My.Computer.Network.NetworkAvailabilityChanged, _
AddressOf MyComputerNetwork_NetworkAvailabilityChanged
End Sub
...
...
Private Sub Init()
Handle_NetworkAvailabilityChanged()
End Sub
For more information (and the original example) you can look at
My.Computer.Network.NetworkAvailabilityChanged Event[
^].
Regards,
Daniele.