asp.netmultithreadinghttpcontextlifecyclehttpapplication

How are Threads created and managed by the HttpApplication?


How are threads created and managed by the HttpApplication in ASP.NET?

What determines if an HttpContext opens a new thread or uses an existing thread? How can this be controlled?

I will be happy with either a solid explanation or a link to a sufficient resource on this information.


Solution

  • How are Threads created and managed by the HttpApplication in ASP.NET?

    They are drawn from a thread pool. They are not created at each request.

    What determines if an HttpContext opens a new thread or uses an existing thread?

    New threads are never created. They are drawn from the pool and returned to it once the request has been serviced.

    How can this be controlled?

    This is something that ASP.NET does very well and not something you want to control but you if you really insist on here's an article which explains how you could use STA threads instead of MTA threads in ASP.NET.