Application Events Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  • Press F5.

Demonstrates

The MainForm contains a StatusStrip control that indicates whether the network connection is currently connected or disconnected. Each time the status of network connectivity changes, the My.Computer.Network.NetworkAvailabilityChanged Event event is raised. The handler for this event resides in the My Project\MyEvents.vb file. To access this file, double-click My Project in Solution Explorer. On the Application tab in the Project Designer, click the View Code button. The logic that updates the Status Panel resides in the SetConnectionStatus method of MainForm. Network events in Visual Basic are marshaled back to the main application thread; handlers of these events can, therefore, manipulate the user interface directly.