───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───
Key Terms
Async vs Sync
- Sync → tasks run sequentially, blocks execution flow
- Async → tasks run concurrently, non-blocking
Concurrency vs Parallelism
- Concurrency → multiple tasks run start and complete in overlapping time periods
- Parallelism → multiple tasks run simultaneously using multiple processors
- Event Loop (Python) or Task Scheduler (.NET) → used to manage async execution
Why?
- Improved application responsiveness
- Efficient handling of IO-bound operations
- Better utilization of hardware
- More scalable applications
Async/Await in C#
- Uses
async
andawait
keywords - Based on
Task
andTask<T>
for async operations - A
Task
is a monad- “A monad is just a monoid in the category of endofunctors” 🤓
- A functional grouping of returned data
- A
Task
represents something that happened on a different processor
Await in C#
- The
await
keyword waits for the boolean value ofTask
to be true - When that happens, the data of
Task
is unwrapped by theawait
keyword async
function can then return the data that has been unwrapped to its called
───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───