Following code hangs forever,without visible reason,docs says HttpWebRequest utilize "worker thread" to do it's work,but it seems block UI thread anyway:
AutoResetEvent re = new AutoResetEvent(false);
IAsyncResult a_r= null;
a_r = r.BeginGetRequestStream(x => re.Set(), null);
re.WaitOne();//OK
using (var rs = r.EndGetRequestStream(a_r))
{
rs.Write(...);
a_r= r.BeginGetResponse(x => re.Set(), null);
}
re.WaitOne();//hangs forever
What could be wrong?Is there any difference between BeginGetRequestStream/BeginGetResponse thread usage?
Thanks.
...
Go to the complete details ...