Try this: If the result is between 40 ~ 120, the latency is good, and your connection is good :)
Usage:
PingTimeAverage("stackoverflow.com", 4);
Implementation:
public static double PingTimeAverage(string host, int echoNum)
{
long totalTime = 0;
int timeout = 120;
Ping pingSender = new Ping ();
for (int i = 0; i < echoNum; i++)
{
PingReply reply = pingSender.Send (host, timeout);
if (reply.Status == IPStatus.Success)
{
totalTime += reply.RoundtripTime;
}
}
return totalTime / echoNum;
}