1

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?

Zach Johnson
  • 2,047
  • 6
  • 24
  • 40

1 Answers1

0

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()

Community
  • 1
  • 1
Carlos Landeras
  • 11,025
  • 11
  • 56
  • 82