c# - WPF startup application execute after internet connection connected? -
i'm developing windows application using wpf.the program running in startup , should wait untill internet connection connected, executed. internet connection time connect. therefore im running thread ping(like this) server in space of 3 seconds watch 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 status true program executed. there efficient way of doing this. ideas please??????
there useful networkmanager class on over cp allow check network connection status using netconnectionstatus
enum...
you start timer check network connection every couple of seconds if (networkmanager.netconnectionstatus != netconnectionstatus.connected){}
, wait execute network dependent code until network status changes connected
.
Comments
Post a Comment