检查在Silverlight互联网连接互联网、Silverlight

2023-09-03 06:37:27 作者:三分书生气七分流氓范

我在写一个Silverlight 4应用程序,并想检查当打开安装了浏览器的应用程序,是否存在有效的Internet连接(以下载,然后从我的网站的一些数据)。什么是做到这一点的最好方法是什么?我意识到,我可以把一个尝试捕捉周围的WebRequest,但似乎有点哈克给我。

I'm writing a Silverlight 4 application and would like to check when opening the installed out of browser application, whether there is a valid internet connection (to then download some data from my website). What is the best way to do this? I realise that I could put a try catch around a WebRequest but that seems a bit hacky to me.

修改:我的意思的有效的互联网连接的只是连接到互联网

EDIT: What I meant by valid internet connection is just connected to the internet

推荐答案

您可以直接杀死二鸟一石 Application.CheckAndDownloadUpdateAsync 。当你得到一个 UpdateAvailable 处理 Application.CheckAndDownloadUpdateCompleted ,这将意味着任何一个两件事情 - 你的网站不能达到或没有可用的更新。在这两种情况下,你会知道你需要知道的。

You can just kill two birds with one stone with Application.CheckAndDownloadUpdateAsync. When you get a False on UpdateAvailable in handling Application.CheckAndDownloadUpdateCompleted, it's going to mean either one of two things - your site can't be reached or there is no update available. In either case, you'll know what you need to know.

 
精彩推荐