문제

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