Bloom.web.UrlLookup.IsInternetAvailable C# (CSharp) Method

IsInternetAvailable() public static method

Check whether or not the internet is currently available. This may delay 2.5 seconds if the computer is on a local network, but the internet is inaccessible.
credit is due to http://stackoverflow.com/questions/520347/how-do-i-check-for-a-network-connection and https://forums.xamarin.com/discussion/19491/check-internet-connectivity.
public static IsInternetAvailable ( ) : bool
return bool
        public static bool IsInternetAvailable()
        {
            // The next line detects whether the computer is hooked up to a local network, wired or wireless.
            // If it's not on a network at all, we know the Internet isn't available!
            var networkConnected = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
            if (!networkConnected)
            {
                _internetAvailable = false;
                return false;
            }
            // Test whether we can talk to a known site of interest on the internet.  This will tell us
            // close enough whether or not the internet is available.
            try
            {
                // test site same as what we use to talk to Amazon S3
                var iNetRequest = (HttpWebRequest)WebRequest.Create("https://s3.amazonaws.com");
                iNetRequest.Timeout = 2500;
                var iNetResponse = iNetRequest.GetResponse();
                iNetResponse.Close();
                _internetAvailable = true;
                return true;
            }
            catch (WebException ex)
            {
                _internetAvailable = false;
                return false;
            }
        }