Stephen Toub: Task-Based Asynchrony with Async

Sign in to queue

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!

Embed

Download

Download this episode

The Discussion

  • User profile image
    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. 

  • User profile image
    Djeez

    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?

    By the way, as a reassurance: I watched the video to the very end.

    Thanks a lot!

  • User profile image
    Rodney McKay

    @Charles: Watched it till the end and loved every single minute Wink
    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 Smiley

    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?

  • User profile image
    Toub

    Hi Rodney-

    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.

  • User profile image
    Rodney McKay

    Thank you Stephen, great work!

    Last week i worked with HttpWebRequest and it looks like this:

    this.webRequest.BeginGetRequestStream(this.OnGetRequestStream, null);
    ...
    private void OnGetRequestStream(IAsyncResult ar)
       this.webRequest.EndGetRequestStream(ar);
       this.webRequest.BeginGetResponse(this.OnGetResponse, null);
    ...
    private void OnGetResponse(IAsyncResult ar)
      this.webRequest.EndGetResponse(ar);
    ...

    Looking forward to async/await Wink

  • User profile image
    ShinNoNoir

    Nice video. The stuff about ActionBlock and dataflow programming reminded me of coroutines in Python. Smiley

  • User profile image
    qwerty

    What about tail recursion in C#5.0? I think tail recursion and async will fit each other very well. Don't they?

  • User profile image
    koistya

    Thanks, Stephen. Great introduction video! That would be good to have some testing project with samples to play with.

  • User profile image
    Avner

    @koistya: You can download the Async CTP here http://msdn.microsoft.com/en-us/vstudio/async.aspx it contain many samples.

  • User profile image
    abhi2434

    Really cool, I liked the way he demonstrated.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.