|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Occurs when the network availability changes.
' Usage Public Sub Me_NetworkAvailabilityChanged( _ ByVal sender As Object, _ ByVal e As NetworkAvailableEventArgs _ ) Handles Me.NetworkAvailabilityChanged End Sub ' Declaration Public Event NetworkAvailabilityChanged( _ ByVal sender As Object, _ ByVal e As NetworkAvailableEventArgs _ )
Required. The Object that raised the event.
Required. Aobject that contains information about the availability of the network.
An application raises the NetworkAvailabilityChanged event every time the availability of the network changes. You can use the e parameter to get the new state of the network connection. To get the current state of the network connection, use the .property of the
This event is raised on the application's main thread with the other user-interface events. This allows the event handler to access directly the application's UI. However, if the application is busy handling another user-interface event when this event is raised, this event cannot be processed until the other event handler finishes or calls the.
Theprovides the same functionality as this event but is available for all application types.
The code for the NetworkAvailabilityChanged event handler is stored in the ApplicationEvents.vb file, which is hidden by default.
To access the Code Editor window for application events
Have a project selected in Solution Explorer. Click Properties on the Project menu.
Click the Application tab.
Click the View Application Events button to open the Code Editor.
For more information, see.
Many network hubs will provide a network connection even if the hub is disconnected from a larger network. Consequently, for wired connections, this event indicates change in the connection between the computer and a hub.
The NetworkAvailabilityChanged event is not raised by applications when run on Windows 95 and Windows 98, or when run by a non-administrator on Windows 2000. If your application might run on those platforms, use theto check for network availability.
This example calls the SetConnectionStatus method of the default Form1 class when the network availability changes.
You must enter the code in the Code Editor window for application events. To access this window, follow the instructions from this topic's Remarks section.