Get the most out of it.
10 Days Trail
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
If you want to check whether the internet connection is available on application life time, you can have a timer and check whether the connection is available. If not you can set warning for the user.
Here how I done that in WPF.
using System.Threading; using System;namespace Example {
public partial class MainWindow : Window{private Timer timer;public MainWindow() { InitializeComponent(); if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {MessageBox.Show("Internet connection not available, \n Please check your connection");return;
} timer = new Timer(UpdateNetworkStatus, null, new TimeSpan(0, 0, 0, 0, 500), new TimeSpan(0, 0, 0, 0, 500)); lblNetworkStatus.Visibility = Visibility.Collapsed; }private void UpdateNetworkStatus(object o) { if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) lblNetworkStatus.Visibility = Visibility.Visible; else lblNetworkStatus.Visibility = Visibility.Collapsed; }}}Will clean this a bit and describe the other ways once I got free time.I just write this blog post because I thought that it will helpful for most of the developers.Cheers!!!