asp.net mvc - Where does the worker thread come from on an async MVC action? -



asp.net mvc - Where does the worker thread come from on an async MVC action? -

imagine action:

public async task<actionresult> myaction(){ var result = await mymethodasync(); homecoming view(result); }

understand making action async, release thread executing action thread pool while mymethodasync() executes, can used serve other http requests. i'm wondering: thread executes mymethodasync()? i'm guessing it's not thread thread pool, since defeat purpose of async actions. brand new thread created, started , destroyed when http response finished?

no still comes thread pool, , not defeat purpose.

async comes becomes valuable during blocking operations, accessing disk or network, not cpu-bound (i.e., operations i/o (input/output) bound).

the thread returned pool doesn't have wait blocking operation finish before can help service http request.

once blocking operation complete, worker thread grabbed from pool.

this can help counteract called thread pool starvation. each thread pool spins many threads, , spinning more expensive. case web server can tied many threads waiting blocking operations complete, new requests have wait new thread, meaning have wait else's blocking operation. async, thread waiting on blocking operation can returned pool can service other (possibly cpu-bound) requests.

read this: http://msdn.microsoft.com/en-us/library/ee728598(vs.100).aspx

...and read this: http://blog.stephencleary.com/2013/11/there-is-no-thread.html

i understand thread grabbed pool 1 time blocking operation done, don't know thread executes blocking operation itself.

no thread executes blocking operation. cpu waiting on device -- network card, or disk controller, homecoming output.

threads cpu-bound artifacts, ram, since operates on buss according cpu clock rate. there other devices in machine usb, network card, disks, etc. these other devices i/o bound because input/output devices.

asp.net-mvc multithreading asynchronous threadpool

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -