iis - How to specify a timeout value on HttpWebRequest.BeginGetResponse without blocking the thread -


I am trying to issue asynchronous release of web requests. My code is working fine except for one thing: There is no built-in method to specify a timeout at BeginGetResponse . The example of MSDN clearly shows an example, but the downside is that they all end with

  some objects. VoteOne ()  

which again explicitly tells that this thread blocks it I will be in a high load environment and can not block, but I have more than 2 seconds There is a need to make a request even if it takes time. I lack the ability to create and manage a separate thread pool, is there something already in the framework that can help me?

  • Code> BeginGetResponse () is a way for the callback to enclose, with some indication that the time has expired.

    The obvious timeout parameter is not respected on the async call unless the return return is returned, the ReadWriteTimeout parameter does not play a non-ownership The solution would be better.

    Edit:

    This is how I came: After calling BeginGetResponse , I am creating a timer and it is the end of the "starting" phase of processing. Now either the request will be completed and my "end" phase will be called or the expiration period will be over.

    If you are the only winner to find the race and if I have the same winner - if the "timeout" is the first thing to come back safely, then I cancel the request and stop the timer I am In this situation, when "End" is called EndgateRanspence , throws an error if the "end" phase occurs first, this counter increases and leaving the "timeout" after canceling the request is.

    It looks like I want to provide a configurable timeout. Negative side is the additional timer object and callback I do not try to avoid. Let me process 1-3 thread different parts (start, end time, end), so it seems that it is working and I do not have a "wait" call.

    Did I not get much sleep or have I found a way to serve uninterrupted requests?

    You can run your HttpWebRequest in separate threads , So your main thread is still alive, so this background thread will be blocked, but not before.

    In this context, you can use the ManualResetEvent.WaitOne () as a sample: method.


    Comments

    Popular posts from this blog

    oracle - The fastest way to check if some records in a database table? -

    php - multilevel menu with multilevel array -

    jQuery UI: Datepicker month format -