Snippet - Check Network Availablity without blocking

[title]Check Network Availablity without blocking[/title]
http://code.tinyclr.com/project/455/check-network-availablity-without-blocking/
[line]
This snippet help you check if network is avalible by checking some public DNS (In example I use 8.8.8.8 which is one of google DNS) without blocking whole device.

Thanks for sharing

Some feedback:

  1. Because of “time < _ping_timeout”, it will always block for at least 5 seconds even if the response was instant

  2. Without “time < _ping_timeout”, network_online_checking will not be set to true in time and the while loop will be skipped over before the thread has even started

I’d suggest replacing:

check_online.Start();

while (network_online_checking && time < _ping_timeout)

With:

network_online_checking = true;
check_online.Start();

while (network_online_checking)

Link to new codeshare:
https://www.ghielectronics.com/community/codeshare/entry/391