───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───
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
asyncandawaitkeywords - Based on
TaskandTask<T>for async operations - A
Taskis a monad- “A monad is just a monoid in the category of endofunctors” 🤓
- A functional grouping of returned data
- A
Taskrepresents something that happened on a different processor
Await in C#
- The
awaitkeyword waits for the boolean value ofTaskto be true - When that happens, the data of
Taskis unwrapped by theawaitkeyword asyncfunction can then return the data that has been unwrapped to its called
───✱*.。:。✱*.:。✧*.。✰*.:。✧*.。:。*.。✱ ───