Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm still having a hard time with async. I see lot's of async code using Tasks, pretty much 99% of the time. Wouldn't this make async code using threads anyway?


Async code, down in the "guts" of the system, will borrow user-level and OS-level threads, so while it's correct that it does use threads, it won't spawn off new ones. Spawning off a new thread ultimately wouldn't accomplish much (after all, why not have IIS just use a new one?).

I like to think of it as utilizing the operating system more efficiently. I/O on a system is asynchronous by default. Async code will essentially delegate work so the OS can do what it does best!


A task may or may not be run on another thread. It just represents a unit of work with a potential result.

It can be confusing because Task objects original main use was running stuff on background worker threads. That is no longer the case.

Note, you can use async and threads. But a lot of code using async and task are NOT using threads.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: