Stephen Toub: Task-Based Asynchrony with Async

Description

Stephen Toub goes deep into the design and architecture of the new Async features in C# and VB.NET, which rely heavily on .NET’s Task Parallel Library. You can get an early look at this new async programming model, available as the Async CTP, today!

The Discussion

Kang Su

Wow, nice job Stephen (and team)! I'm going to play with this some, but it looks like I can start writing some of our UI in a more readable manner, rather than some of the craziness I'm doing now to keep a responsive UI.

Very informative interview! I watched the other video's on async as well, but this was the best. What came somewhat as a surprise was the introduction of DataFlows, which in the interview appeared as a coincedence because of the CCR talks. So I wonder if we can have an interview on an overview of what this CTP brings us. I mean, we have learned about the basics, and now about DataFlows, but are there any more goodies?

@Charles: Watched it till the end and loved every single minute Thank you Stephan, Thank you Charles.

Unfortunately we have to wait until Visual Studio 2012 right? Of course i can play with the CTP but it would be nice to have it ready for production code right away

Another questions: if i use the async/await keywords on the UI-thread it is guaranteed that the code continues on the UI-thread. If i use it on any other thread, does it continue on a thread pool thread? It can't be the same thread that started the operation right?

Regarding which thread things run on, awaiting a task attempts to resume execution in the same threading environment where the operation was suspended. If there was a current SynchronizationContext when the await began, then execution will resume on that context (by Post'ing to it); otherwise, execution will begin on whatever TaskScheduler was current at the await. This means that if you await on a UI thread, execution will continue on the UI thread. If you await on a threadpool thread, you'll resume on a thread pool thread, though not necessarily the same thread that began the await.