开发者

How to check connection services when using webservices?

In my app I'm using webservices and if internet connection is true, my app runs very good. Without internet my application generates an error. So how can I check internet connection before my application is connected to services. Because I cannot work with applications tuogn although I did

try {} 
catch {开发者_C百科}

So, my app is errors in servicesReferent. How do I do if the case does not have an internet connection, or faulty services?


You can use GetIsNetworkAvailable in the NetworkInterface class from the System.Net.NetworkInformation namespace

for example

   bool isNetworkAvaiable =  NetworkInterface.GetIsNetworkAvailable()


Be aware that if you connect a WP7 to your development workstation using the USB cable, it will use your workstation's internet connection and this is almost certainly why you always see the network as being available when you are debugging. Disconnecting your workstation from the local network won't help because from the phone's perspective it's still connected to a network (containing two hosts, itself and your workstation) even when that network doesn't have a gateway to anything else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜