Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found the cause for this, methinks:</p> <p>This method is in the WrappedAsyncResult class, which the MvcHandler class uses via BeginProcessRequest:</p> <pre><code>public static IAsyncResult BeginSynchronous&lt;TResult&gt;(AsyncCallback callback, object state, Func&lt;TResult&gt; func, object tag) { BeginInvokeDelegate beginDelegate = delegate (AsyncCallback asyncCallback, object asyncState) { SimpleAsyncResult result = new SimpleAsyncResult(asyncState); result.MarkCompleted(true, asyncCallback); return result; }; EndInvokeDelegate&lt;TResult&gt; endDelegate = _ =&gt; func(); WrappedAsyncResult&lt;TResult&gt; result = new WrappedAsyncResult&lt;TResult&gt;(beginDelegate, endDelegate, tag); result.Begin(callback, state, -1); return result; } </code></pre> <p>where "Begin" is:</p> <pre><code>public void Begin(AsyncCallback callback, object state, int timeout) { bool completedSynchronously; this._originalCallback = callback; lock (this._beginDelegateLockObj) { this._innerAsyncResult = this._beginDelegate(new AsyncCallback(this.HandleAsynchronousCompletion), state); completedSynchronously = this._innerAsyncResult.CompletedSynchronously; if (!completedSynchronously &amp;&amp; (timeout &gt; -1)) { this.CreateTimer(timeout); } } if (completedSynchronously &amp;&amp; (callback != null)) { callback(this); } } </code></pre> <p>EDIT: have come up with a ham-handed way of forcing MVC controller actions to "time out", although the mechanism is a bit brutish:</p> <pre><code>public class TimeoutController : Controller { private bool _isExecuting = false; private int _controllerTimeout = 5000; private Thread _executingThread; private readonly object _syncRoot = new object(); protected override void ExecuteCore() { _executingThread = Thread.CurrentThread; ThreadPool.QueueUserWorkItem(o =&gt; { Thread.Sleep(_controllerTimeout); if (_isExecuting) { _executingThread.Abort(); } }); base.ExecuteCore(); } protected override void OnActionExecuting(ActionExecutingContext filterContext) { _isExecuting = true; base.OnActionExecuting(filterContext); } protected override void OnActionExecuted(ActionExecutedContext filterContext) { _isExecuting = false; base.OnActionExecuted(filterContext); } public int ControllerTimeout { get { int retVal; lock(_syncRoot) { retVal = _controllerTimeout; } return retVal; } set { lock(_syncRoot) { _controllerTimeout = value; } } } } </code></pre>
 

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