Three Essential Tips for Using Async in Microsoft Visual C# and Visual Basic

Play Three Essential Tips for Using Async in Microsoft Visual C# and Visual Basic
Sign in to queue


You might already be using the new async language features in your C# or Visual Basic code—but are you using them effectively? Here are three essential tips to keep in mind: only use async void for event handlers; only use the threadpool for CPU-bound work; and use TaskCompletionSource to wrap events into Tasks. In this session, learn how to recognize bad async code smells, what the best-practice alternatives are, and why they’re important. The tips in this talk are a distillation of real-world practical experience that you'll put to use immediately.





Session Type:





Hall 7.5



Download this episode

The Discussion

  • User profile image
  • User profile image

    Very informative and helpful in understanding the flow of control in an asynchronous event handler. The message pump, the processing of those messages, and the completion of a message loop is how I understand this "void" return notion better. Oh, and thank you for sharing the Silverlight group panel example. ASP.NET can use thread pool threads, but from  what I have read, Silverlight, WPF, Windows Forms, and Windows Store apps map an application design model with a threading model that only permits that single thread that created the UI to update that UI. An event handler that returns a Task would have prevented partial print-outs because all of the requested data had not yet populated that panel control.  An async marked event handler that returns a Task would rule have an await expression: the control flow would execute in a more sequential order, despite the pausing point and continuations.

    Many Thanks

  • User profile image

    I found Lucian the most knowledgeable on Async programming style. His code samples, presentation and knowledge...all top grades, awesome talk!

Add Your 2 Cents