F
Finn Stampe Mikkelsen
Hi
I need to have my program be Internet aware and constantly know, wether the internet i avaiable to it.. I have tried with this code:
[DllImport("wininet.dll")]private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ;
//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}
So far so good. It works okay. I've put the call in a timer event, which checks the availability every tick. When however the
internet connections breaks, the UI gets extremely slow and reactions to user actions is slowed down considerably...
Is there a better way to do this??
I've tried to delay my check for Inet to the actual code, where i need to know if there is a connection to the internet, but thsi
still slows down the handlings, so i must conclude that the above code has a long timeout when internet is not available.
I have tried using other methods of checking internet availability, such as creating an tcpclient and connecting,
System.Net.Dns.GetHostByName("www.google.com"), but all have the same result... When internet is not available, the software is
extremely slow...
Is there a way to do this, without the code slowing down??
/Finn
I need to have my program be Internet aware and constantly know, wether the internet i avaiable to it.. I have tried with this code:
[DllImport("wininet.dll")]private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ;
//Creating a function that uses the API function...
public static bool IsConnectedToInternet( )
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}
So far so good. It works okay. I've put the call in a timer event, which checks the availability every tick. When however the
internet connections breaks, the UI gets extremely slow and reactions to user actions is slowed down considerably...
Is there a better way to do this??
I've tried to delay my check for Inet to the actual code, where i need to know if there is a connection to the internet, but thsi
still slows down the handlings, so i must conclude that the above code has a long timeout when internet is not available.
I have tried using other methods of checking internet availability, such as creating an tcpclient and connecting,
System.Net.Dns.GetHostByName("www.google.com"), but all have the same result... When internet is not available, the software is
extremely slow...
Is there a way to do this, without the code slowing down??
/Finn