How can I use HttpWebRequest (.NET, C#) asynchronously?
+3
A:
Check out this article on Developer Fusion: http://www.developerfusion.com/code/4654/asynchronous-httpwebrequest/
Jeremy Reagan
2008-10-14 19:24:01
+14
A:
Use HttpWebRequest.BeginGetResponse()
HttpWebRequest webRequest;
void StartWebRequest()
{
webRequest.BeginGetResponse(new AsyncCallback(FinishWebRequest), null);
}
void FinishWebRequest(IAsyncResult result)
{
webRequest.EndGetResponse(result);
}
The callback function is called when the asynchronous operation is complete. You need to at least call EndGetResponse()
from this function.
Jon B
2008-10-14 21:17:56
+1
A:
You can also see the following, for a pretty complete example of doing what Jason is asking:
http://stuff.seans.com/2009/01/05/using-httpwebrequest-for-asynchronous-downloads/
Sean
Sean Sexton
2009-04-08 19:43:41
A:
Raj Kaimal
2010-03-26 22:55:41
for a moment, I wondered if you were trying to comment on a recursive thread?
Kyle Hodgson
2010-05-20 03:17:18
Copy and paste error. Fixed. Thanks Kyle!
Raj Kaimal
2010-05-21 04:09:20