views:

588

answers:

1

Referencing this question: http://stackoverflow.com/questions/435492/is-asp-net-multithreaded-how-does-it-execute-requests, would this be a correct interpretation of threading: ASP.NET has one worker process per application instance. It is multi-threaded, using its own application pool. The majority of threads are used for servicing (user) request. Each request (user session) is one thread. The corresponding response may be another thread. User request come as multiple threads from ISAPI, which is itself multi-threaded.

AJAX is not multi-threaded. It uses the same threading model as non AJAX websites. The page request (ajax or non ajax) may cause multiple threads to be used on the server but it is still one thread on the client (browser uses a single thread).

+1  A: 

In short, yes. In ASP.NET the request/response are normally handled in a single thread... there is no clear distinction between "request" and "response", it's simply ISAPI passing the request info to the ASP.NET handler and it will execute the appropriate code and write an output. (Although there is a mechanism for migrating a request from one thread to another. I am not 100% sure on when or why this happens.)

Browser-side JavaScript and AJAX are not multi-threaded, but it can appear that way to some because AJAX calls are asynchronous and the responses are event-driven; that is, once the request is dispatched to the server, the JavaScript thread is not blocked. It is free to send more requests to the server, and the responses may or may not come back in the same order they were sent. However, because at the core there really is only one thread, if two responses come back at the same time, one will block execution of the other until it is finished.

Rex M