0

I'm using IHttpAsyncHandler with BeginProcessRequest and EndProcessRequest methods. Say I have the following code under EndProcessRequest method:

    public void EndProcessRequest(IAsyncResult result)
    {
         result.Context.Response.Write("Some message");
    }

The Write method itself only writes to an inner buffer, but when the EndProcessRequest is finished, the buffer is flushed to the stream and close the connection.

My question is which thread is doing the flush? the worker thread which ran the EndProcessRequest code or an IO thread?

Tomer Peled
  • 3,571
  • 5
  • 35
  • 57
  • 1
    You should probably structure your program so that it doesn't matter. – Servy Jan 21 '15 at 15:47
  • This is partly correct :) But say I have my current implementation with this IHttpAsyncHandler and I want to be sure that I'm optimized in the manner of the running time of my worker thread - which means that the flush operation should be done only by the IO thread - so that the worker thread won't need to wait for the IO thread to complete - how can I achieve that? – Tomer Peled Jan 21 '15 at 16:01
  • @TomerPeled I see now what you are looking for - I don't know and my answer does not really apply to mapping between [native](https://msdn.microsoft.com/en-us/library/windows/desktop/ms686756%28v=vs.85%29.aspx) an manged threadpools/threading in IIS. Deleted the answer as I believe I totally misunderstood the question: "I don't want that the flush operation will consume a worker thread time." – Alexei Levenkov Jan 21 '15 at 21:16

0 Answers0