質問

I am downloading a string via system.net.WebClient

I am also downloading it using a proxy:

 Dim proxy As New Net.WebProxy(grabbedproxy.ToString)
     webClient.Proxy = proxy

My basic problem is that I have no idea how to make the downloadstring request timeout after a certain amoun of time. If the proxy being used is slow it makes my program hang for minutes. Is there any way to set a timeout time for the proxy so that it will dissconnect itself after a certain amount of seconds?

役に立ちましたか?

解決

Using WebClient.DownloadFileAsync() allows you to use CancelAsync() by timer using your own timeout value.

Check also this post, it shows you how to implement a derived class with timeout:

Set timeout for webClient.DownloadFile()

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top