Community discussion forum

Asynchronous HttpWebRequest

This is a comment thread discussing Asynchronous HttpWebRequest
  • 9 years ago

    This thread is for discussions of Asynchronous HttpWebRequest.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 2 years ago

    Hi Steven

    I've got the following problem and your proposal seems to be the solution:

    I want to do a asynchronous Request, where I have to post a large amount of data to some old asp - component. "Asynchronous" means for me to start the posting and imideately continue with my workflow while in background the huge amount of data is posting...

    therrefore I call as suggested in msdn - help:

    // Start the asynchronous request.

    IAsyncResult result = ( IAsyncResult ) httpRequest.BeginGetResponse ( new AsyncCallback ( RespCallback ), state );

    // this line implements the timeout, if there is a timeout, the callback fires and the request becomes aborted

    ThreadPool.RegisterWaitForSingleObject (
    result.AsyncWaitHandle, new WaitOrTimerCallback ( TimeoutCallback ),
    httpRequest, DefaultTimeout, true );

    Now I set my breakpoint in the RespCallback() - Method and here'se the problem:
    after BeginGetResponse () the process first jumps to RespCallback() and then jumps to RegisterWaitForSingleObject()

    So this is not realy asynchronous...
    Did I miss something or is this general behaviour ?

    after trying your solution (perform this request in an extra thread) I saw that this would be the right way but I have some questions left:

    If you start this request in an extra thread, why do you make this request asynchronous ?
    I think, asynchronity in this place is achieved by the extra thread which runs in the background

    Is there a way to achieve the asynchronity I want without this extra thread (I'm not sure that what I want realy matches the meaning of "asynchronity" used by BeginGetResponse() ... EndGetResponse() ) ?


    thanx in advance and nice greetings
      Bernd


















  • 1 year ago

    "Careful with that Axe Eugene" - I love that song.

     

Post a reply

Enter your message below

Sign in or Join us (it's free).