Three Essential Tips For Async - Introduction | Three Essential Tips for Async

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Async involves some new concepts. Theyre not difficult; just unfamiliar. Over the past year Lucian Wischik has been watching how people use async/await in C# and VB. This series distils out the three top async patterns and anti-patterns.
Tips:
  1. Async void is for top-level event-handlers only, and event-like things. Dont use it elsewhere in your code.
  2. Its crucial to distinguish CPU-bound work (should be done on threadpool) from IO-bound work (which neednt).

  3. You can wrap events up in Task-returning APIs and await them. This can dramatically simplify code.
If you understand the basic flow of control in an async method, then those three points all fall naturally into place. This first introduction video explains that control flow.

Slides and source code are available on Lucians blog.
1064b47e981379ce0062a2b2eac4379b.gif


View the full article
 
Back
Top