【发布时间】:2016-07-20 11:28:45
【问题描述】:
我的 C# windows 窗体应用程序从 url 下载一个短字符串。它解析字符串并显示信息。它纯粹用于此目的。一种弹出式程序。我正在使用这个:
using (WebClient wc = new WebClient())
{
string json = wc.DownloadString(url);
//parse the string
//show windows form with the gathered data
this.Show()
}
我的问题是,当没有互联网连接时,会弹出未处理的异常错误。我认为我需要防止出现此错误消息并保持程序滚动直到连接恢复。如何阻止消息并使其保持运行?
【问题讨论】:
-
有一种众所周知的方法可以检查互联网连接是否可用(尽管并不总是正确)stackoverflow.com/questions/13625304/…
标签: c# winforms exception exception-handling