Search code examples
c#asp.net-mvc-3asynccontroller

AsyncController: Interference having 2 async methods


i'm having an AsyncController that has 2 AsyncMethods. One is called GetMessages, the other Check. It seems, that one call blocks the other, probably because both call this.AsyncManager.OutstandingOperations.Increment(); Do they share the same AsyncManager? What is the right way to do that? Do i have to have 2 AsyncController to ensure that they dont get in each others way?

Update: The code of both methods is similar to code posted here: Async operation completes, but result is not send to browser

in fact, it is the same controller, only added the Check/CheckCompleted. sometimes, the "Check" has to get triggered so that the "GetMessages" returns

Update2: I have a waittimout of 60 seconds for both methods. I reduced one now to 5, this helps it, but i think it is just a hack.


Solution

  • They shouldn't block. The blocking you are observing might be due to the fact that both methods use Session and because Session is not thread safe, ASP.NET blocks access if you have two parallel requests from the same session (for example AJAX requests).

    So try disabling all session for those actions by decorating them with the following attribute:

    [SessionState(SessionStateBehavior.Disabled)]