I have an windows app that 99 percent of the time will write to a sql database on the network.
But there are times when the network might go down and I want to go to a "local" mode.
So I was wanting to ping the server if its up and write to it, if not I will write locally.
The problem I am seeing is in my little test environment everything goes smoothly. However If i plug my network cable back in and ping the server there is a slow response as the computer seems to be trying to resolve an ip address etc.
I have tried a couple different ways to test connectivity and get that same lag as they network card seems to try and connect back to the network.
I am trying to get an immediate true or false condition.
But there are times when the network might go down and I want to go to a "local" mode.
So I was wanting to ping the server if its up and write to it, if not I will write locally.
The problem I am seeing is in my little test environment everything goes smoothly. However If i plug my network cable back in and ping the server there is a slow response as the computer seems to be trying to resolve an ip address etc.
I have tried a couple different ways to test connectivity and get that same lag as they network card seems to try and connect back to the network.
I am trying to get an immediate true or false condition.
Code:
var ping = new System.Net.NetworkInformation.Ping();
var result = ping.Send("washington");
if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
Code:
private Boolean isNetworkUp()
{
bool networkUp = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
return networkUp;
}