11.2. Detect Changes in Network Connectivity

Problem

You need a mechanism to check whether changes to the network occur during the life of your application.

Solution

Add handlers to the Shared NetworkAddressChanged and NetworkAvailabilityChanged events implemented by the System.Net.NetworkInformation.NetworkChange class. The My object also offers a shared NetworkAvailabilityChanged event. This event is implemented by the My.Computer.Network class, which is part of the Microsoft.VisualBasic.Devices namespace. (See Chapter 5 for more information about the My object.)

How It Works

The NetworkChange class provides an easy-to-use mechanism that allows applications to be aware of changes to network addresses and general network availability. This ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.