I'm developing a windows application using WPF.The program is running in the startup and should wait untill the internet connection is connected, to be executed. Normally internet connection will get some time to connect. Therefore now im running a thread to ping(like this) with the server in space of 3 seconds to watch the connection status.
public bool CheckConnection()
{
try
{
//////////////check connction
System.Net.Sockets.TcpClient clnt = new System.Net.Sockets.TcpClient(UserConfig.configlist[2], Convert.ToInt32(UserConfig.configlist[3]));
clnt.Close();
return true;
}
catch (Exception)
{
return false;
}
}
If the status is true program will be executed. Is there any efficient way of doing this. Any ideas please??????