检查在Silverlight互联网连接 [英] Check internet connection in Silverlight
问题描述
我在写一个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
推荐答案
您可以直接杀死二鸟一石<一个href="http://msdn.microsoft.com/en-us/library/system.windows.application.checkanddownloadupdateasync%28VS.95%29.aspx"相对=nofollow> Application.CheckAndDownloadUpdateAsync 。当你得到一个假
在 UpdateAvailable
处理<一href="http://msdn.microsoft.com/en-us/library/system.windows.application.checkanddownloadupdatecompleted%28v=VS.95%29.aspx"相对=nofollow> 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.
这篇关于检查在Silverlight互联网连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!