

All I need to do is to ping the nearest thing to me that is on the internet. Pinging 8.8.8.8 is fine but Google is several hops away from me. Pinging introduces a DNS resolution dependency. Void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)ĭispatcher.Invoke(DispatcherPriority.Normal, new Action(() => Volatile bool internetAvailable = false // boolean used elsewhere in code WebClient.OpenReadCompleted += webClient_OpenReadCompleted WebClient.CachePolicy = new (.BypassCache) Using (WebClient webClient = new WebClient()) Void CheckInternetConnectivity(object state) Here is the solution that I ended up using, with the help of some of these answers and my colleagues: // Insert this where check is required, in my case program start


Some of the responses on this page were very good, but did however cause a lot of performance issues such as hanging, mainly in the case of the absence of connectivity. This functionality was to be disabled where a lack of internet connectivity was noted. I recently ran into this problem making an application which including a mapping feature which linked to an on-line tile server. Surely there is a degree of uncertainty in many programming tasks we as developers undertake, but reducing the uncertainty to a level of acceptance is part of the challenge. I disagree with people who are stating: "What's the point in checking for connectivity before performing a task, as immediately after the check the connection may be lost".
