c# - WebClient Timeout solution doesn't work (subclassing to set Timeout) -


i trying use commonly accepted solution setting timeouts weblclient calls. in test case of requesting url offline machine: consistently 20 second timeouts when set @ 1 second.

public class timeoutwebclient : webclient {     public timeoutwebclient(timespan timeout)     {         _timeout = timeout;     }     private timespan _timeout;     protected override webrequest getwebrequest(uri address)    {        webrequest request = base.getwebrequest(address);        request.timeout = (int)_timeout.totalmilliseconds;        return request;    } } 

server based timeouts can't matter in scenario. missing?

i did find snippet set both httpwebrequest.readwritetimeout , httpwebrequest.servicepoint.maxidletime. setting these timeout value still didn't make difference , still getting ~20 second timeouts.

any other thoughts of cause behavior?

any chance using async download method?

from msdn:

the timeout property affects synchronous requests made getresponse method. time out asynchronous requests, use abort method.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -