我试图把我的外部IP放在一个标签上,所以我是基于一个站点下载结果的,但是当我通过VPN改变我的IP时,应用程序崩溃了,我相信这是因为它没有检查它是否正在下载字符串,他尝试了。
在形式上..。
If Label1.Text = LastIp Then
Try
Dim wc As New WebClient
Label1.Text = wc.DownloadString("http://icanhazip.com/")
If you can not then
Label.Text = "Failed to get IP"
End if
End If表格.

发布于 2017-12-03 14:05:09
您可以设置回调并指定文件的路径:
Dim wc As New WebClient
AddHandler wc.DownloadStringCompleted, AddressOf DownloadStringComplete
wc.DownloadStringAsync(New Uri("http://icanhazip.com/myfile.txt", UriKind.Absolute))
Private Sub DownloadStringComplete(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs)
If Not IsNothing(e.Error) Then
Label1.Text = e.Error.Message
ElseIf e.Cancelled Then
Label1.Text = "canceled"
Else
Label1.Text = e.Result
End If
End Subhttps://stackoverflow.com/questions/47615612
复制相似问题