Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I came across this article 2 days ago when I had the same problem. I tried everything, it worked on my local machine but did not work on the production server. Today, I have a workaround that fixes the problem and would like to share. Microsoft seems to not apply timeout to IHttpAsyncHandler and I take advantage of that. On my system, I only have 1 handler that is time-consuming, so this solution works for me. My handler code looks like this:</p> <pre><code>public class Handler1 : IHttpAsyncHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { } public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData) { //My business logic is here AsynchOperation asynch = new AsynchOperation(cb, context, extraData); asynch.StartAsyncWork(); return asynch; } public void EndProcessRequest(IAsyncResult result) { } } </code></pre> <p>And my helper class:</p> <pre><code>class AsynchOperation : IAsyncResult { private bool _completed; private Object _state; private AsyncCallback _callback; private HttpContext _context; bool IAsyncResult.IsCompleted { get { return _completed; } } WaitHandle IAsyncResult.AsyncWaitHandle { get { return null; } } Object IAsyncResult.AsyncState { get { return _state; } } bool IAsyncResult.CompletedSynchronously { get { return false; } } public AsynchOperation(AsyncCallback callback, HttpContext context, Object state) { _callback = callback; _context = context; _state = state; _completed = false; } public void StartAsyncWork() { _completed = true; _callback(this); } } </code></pre> <p>In this approach, we actually do not do anything asynchronously. <code>AsynchOperation</code> is just a fake asyn task. All of my business logic is still executed on the main thread which does not change any behavior of the current code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload