Talk: The New Async Design Patterns
Talk: The New Async Design Patterns
Async involves some new concepts. They're not difficult; just unfamiliar. Over the past year I've been watching how people use it. This talk distils out the three top async patterns and anti-patterns.
- Async void is for top-level event-handlers only, and event-like things. Don't use it elsewhere in your code.
- You can wrap events up in Task-returning APIs and await them. This can dramatically simplify code.
- It's crucial to distinguish CPU-bound work (should be done on threadpool) from IO-bound work (which needn't).
If you understand the basic flow of control in an async method, then those three points all fall naturally into place.
- I gave this talk at Techready16 in Seattle, USA on 2013.02.05
- Watch videos online: Intro [5mins], Tip1: async void [20mins], Tip2: async and threads [16mins], Tip3: async-over-events [15mins]
- Download slides.pptx [6.3mb]
- Download script.docx [35k]
- Download VB source_code.zip [460k, requires VS2012 and Win8]
PS. The first anti-pattern is "async void". People of course ask: "If it's so wrong, then why did you allow it?" That's a good question. I'll write a blog post solely on this question next week.