KateWilliams Posted April 25, 2004 Share Posted April 25, 2004 Hi, I am trying to close an HttpWebRequest I requested. However, Close() could take a very long time to return. Does anyone know why and how to solve this? Is there a way I can set a timeout on the Close()? Here's the code: HttpWebRequest req = (HttpWebRequest)WebRequest.Create(pageAddress); req.Timeout=1000; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); . . . resp.Close(); thanks a lot! :) Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/ Share on other sites More sharing options...
0 azcodemonkey Posted April 25, 2004 Share Posted April 25, 2004 You should use an asynchronous call for WebRequest/WebResponse calls. Most things in System.Net kill performance. I'll write up an example for you in a minute. Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/#findComment-2017700 Share on other sites More sharing options...
0 azcodemonkey Posted April 25, 2004 Share Posted April 25, 2004 OK. I'm not sure that this will solve your close problem. I didn't write this. I've been too busy all night since I posted, so I figured I'd point you to a tutorial. http://www.codeproject.com/managedcpp/cswget01.asp Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/#findComment-2018381 Share on other sites More sharing options...
0 KateWilliams Posted April 25, 2004 Author Share Posted April 25, 2004 Thanks a lot! :D Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/#findComment-2021448 Share on other sites More sharing options...
0 HellBender Posted April 25, 2004 Share Posted April 25, 2004 Also, you might want to consider integrating HTTPanties in there. :laugh: Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/#findComment-2021459 Share on other sites More sharing options...
0 azcodemonkey Posted April 26, 2004 Share Posted April 26, 2004 HellBender said: Also, you might want to consider integrating HTTPanties in there. :laugh: ? Not very appropriate. So tell me, HB, are they comfortable? ;) Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/#findComment-2022046 Share on other sites More sharing options...
0 HellBender Posted April 26, 2004 Share Posted April 26, 2004 weenur said: ?Not very appropriate. So tell me, HB, are they comfortable? ;) Sure. They fit excellently on my head :yes: Link to comment https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/#findComment-2022276 Share on other sites More sharing options...
Question
KateWilliams
Hi,
I am trying to close an HttpWebRequest I requested.
However, Close() could take a very long time to return.
Does anyone know why and how to solve this?
Is there a way I can set a timeout on the Close()?
Here's the code:
HttpWebRequest req
= (HttpWebRequest)WebRequest.Create(pageAddress);
req.Timeout=1000;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
.
.
.
resp.Close();
thanks a lot!
:)
Link to comment
https://www.neowin.net/forum/topic/160833-close-httpwebrequest-in-c/Share on other sites
6 answers to this question
Recommended Posts