Konrad wrote:
> I found this method and it is quick
>
> //Creating the extern function...
>
> [DllImport("wininet.dll")]
>
> private extern static bool InternetGetConnectedState(
>
> out int Description, int ReservedValue ) ;
>
>
>
> public static bool IsConnectedToInternet( )
>
> {
>
> int Desc ;
>
> return InternetGetConnectedState( out Desc, 0 ) ;
>
> }
>
>
>
> and previous method
>
> public static bool IsInternetConnected(string url)
>
> {
>
> bool FoundUrl = true;
>
> try
>
> {
>
> WebRequest req;
>
> WebResponse result;
>
> Stream ReceiveStream;
>
> Encoding encode;
>
> StreamReader sr;
>
> req = WebRequest.Create(url);
>
> req.Timeout = 5000;
>
> result = req.GetResponse();
>
> ReceiveStream = result.GetResponseStream();
>
> encode = System.Text.Encoding.GetEncoding("utf-8");
>
> sr = new StreamReader(ReceiveStream, encode);
>
> }
>
> catch(System.Exception e)
>
> {
>
> FoundUrl = false;
>
> }
>
> return FoundUrl;
>
>
> }
>
> Thanks
>
> Konrad
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:2q2sv5Fqlvg4U1@uni-berlin.de...
>
>>* "Konrad" <konrad007@poczta.onet.pl> scripsit:
>>
>>>I'am checking in separate thread does the connection with
>>>internet is estabilished. But program freezes
>>>for 2-3 secs. How to do that user
>>>doesn't feel this checking?
>>
>>How do you check if the connection is established?
>>
>>--
>> M S Herfried K. Wagner
>>M V P <URL:
http://dotnet.mvps.org/> >> V B <URL:
http://dotnet.mvps.org/dotnet/faqs/> >
site, say yahoo or google using System.Net.HttpWebRequest class.
but anyway you can launch it in a separate thread.