Simple, Quality, Awesome Software

Asynchronous Programming Quiz

Below are the answers to the Asynchronous Programming Quiz, along with a brief discussion.

1. Running code on multiple threads, with the goal of utilizing responsiveness or speed.

2. A can, because it is a long-running task that could be spread across multiple threads running simultaneously. B won’t benefit because it’s quick to run. The overhead of making a new thread or handing it off to a thread would outweigh any other benefit. C will, because it frees up the thread while it’s waiting for a response, allowing other work to get done in the mean time.

3. async.

4. await.

5. void, Task, Task<T>, ValueTask<T>.

6. void is B. This kind of asynchronous task is intended to be fire-and-forget. Task is A. You want to know when it finishes, but it doesn’t produce a value as a result. Task<T> is C. It produces a specific result.