SevenDays
SevenDays

Reputation: 3768

How to check if internet connection was lost WP7

How can I check if internet connection was lost in WP7.I'm developing social app and if internet connection was lost I have FileNotFoundException.I can't use try/catch because its doesn't prevent my app from closing with exception.Also if (NetworkInterface.GetIsNetworkAvailable()) works only from time to time and not always shows the truth.

Upvotes: 1

Views: 1911

Answers (4)

Max
Max

Reputation: 1548

@Francesco : I think you are right, NetworkInterface.GetIsNetworkAvailable() works fine on phone, but its unreliable on emulator.

Upvotes: 0

Razor
Razor

Reputation: 1415

        bool isAvailable = NetworkInterface.GetIsNetworkAvailable();
        if (isAvailable == false)
        {
            //Logic here
        }
        else
        {
             //Code
        }

It works all the time for me...

Upvotes: 2

Max
Max

Reputation: 1548

NetworkInterface.GetIsNetworkAvailable() doesnt seem to work correctly all the time. Its better to use WebClient object to download some URL which you are sure is available always.

Upvotes: 0

John Nagle
John Nagle

Reputation: 116

The only reliable way I have found is to ping something reliable. My customer set up a "ping" call on the server that I need to access, which is the ultimate test. If I can reach that call, I can (or shoule be able to) reach any of them.

Upvotes: 4

Related Questions