c# - HttpWebRequest.BeginGetResponse does not work. Test becomes stuck -



c# - HttpWebRequest.BeginGetResponse does not work. Test becomes stuck -

i've been trying utilize httpwebrequest.begingetresponse becomes stuck after countdownevent.wait() called. using httpclient not encountering problem

private static countdownevent latch; [testmethod] public void test001() { latch = new countdownevent(1); httpwebrequest request = (httpwebrequest)webrequest.create("http://www.google.com"); request.begingetresponse(new asynccallback(finish), request); latch.wait(); } private void finish(iasyncresult result) { debug.writeline("finish"); latch.signal(); }

the problem comes fact httpwebrequest.begingetresponse(...) needs ui thread @ point (not synchronously). don't know why that, how is.

in case, method test001() called in ui thread. on latch.wait(); line blocks thread, , request can't made , never completes.

if invoke test001() method on non-ui thread, should work. can't help much more this, don't know how unit test framework works.

c# testing windows-phone-8

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -