DEV Community

Discussion on: Async/Await For The Rest Of Us

Collapse
 
makingloops profile image
Joe Petrakovich

Thanks James, making it clear that for web devs (asp.net) it just frees up the thread for other HTTP requests is a major key. Wish I had read your article sooner :).

I started trying to use it thinking it would put the work on a background thread so the user could keep going, but it only really does that for desktop apps like you mentioned.

Better to use HostingEnvironment.QueueBackgroundWorkItem() for my purposes.

Collapse
 
jamesmh profile image
James Hickey

Thanks for the feedback! Async is hard. Even when you do know how to use it...

Just an extra thought - HostingEnvironment.QueueBackgroundWorkItem() still uses threads from the thread pool in web apps. Triggering many long-running background tasks could actually cause thread starvation in high-demand scenarios.

Take care Joe!