Async / await · interview question
Which async practices are recommended? Select all that apply.
Select all that applyMedium
Answer and explanation
Correct answer
- A. Use
async voidonly for event handlers. - C. Pass a
CancellationTokenthrough async call chains. - D. Use
ConfigureAwait(false)in general-purpose library code.
Why
Async all the way, cancellation tokens, and ConfigureAwait(false) in libraries (which don't need the caller's context) are standard guidance. async void can't be awaited and crashes the process on unhandled exceptions, so reserve it for event handlers.
Test yourself on Async / await
A free test with instant, explained results. No account needed.