AngelSix explains C# Tasks, threads, and the async and await keywords with practical examples of asynchronous code flow.
Support Me: patreon.com/angelsix
Table of Content Below
In a follow on from threads, we really dig deep into Tasks and the async and await keywords, with dozens of real examples, heavy focus on threads, contexts, understanding the real flow of code across the asynchronous barrier.
What is Asynchronous
Issues with Threads
- Issue 1 Expensive to make
- Issue 2 Resuming after thread finish
--- Solution 1 Blocking Wait
--- Solution 2 Polling Wait
--- Solution 3 Event Callback
--- The running and callback threads
What is a Task
Tasks, Async, Await
- Synchronous Method
- Asynchronous Method
Async Analogy
The Synchronous part in Tasks
- Showing the point at which asynchronicity starts
Async Return Types
- Returning a Task of T
- Comsuming a Task of T Method 1
- Comsuming a Task of T Method 2
Async Keyword
Consuming Async Methods
What happens during an Async call
Threads during Async calls
- The Synchronization Context
- ConfigureAwait(false)
Exceptions in Async calls
Async in WPF
- Synchronous in UI
- Asyncronous in UI
- Editing UI after await
- Synchronization Context on UI thread
- Supporting me
Source Code: github.com/angelsix/youtube/tree/67ad430308b32282c25d1ae07bc…
Latest Source Code: github.com/angelsix/youtube/tree/develop/Tasks
Why it's here
1 person recommends this
What people say. Recommended as a detailed explanation of async and await in .NET for developers who get confused by basic use cases.
a
u/anxiousmarcusin r/dotnet • Recommends
…any interviews where the candidates get awfully confused about even very basic use cases.
To people who are unclear about this, let me put this very bluntly with a commonly used analogy. I'm gonna use super simple examples so everyone can benefit. If you're advanced, please ignore this post.
u/Daell provided this link with detailed explanation - link to this video
**SCENARIO**
Think of your server as a Chef and think of making an egg, blending a smoothie, frying some chicken as tasks.
The idea is Chef gets a request to make eggs, blend smoothie and fry some chicken. He gets them done.
***WITHOUT CONCURRENCY***
Chef gets a request to make an egg, chef starts making an egg. Chef gets another reque…