Runtime & concurrency
Reveal answer and reasoning
Writer completion ends admission but does not imply accepted buffered items disappear. A reader can drain those items and still need to observe a successful, faulted, or canceled terminal state through the appropriate channel protocol. Reader.Completion is a lifecycle task, not merely an empty-buffer observation. The lesson deliberately supplies an InvalidOperationException and awaits the terminal task after draining.
A common wrong answer treats every empty read as permanent successful completion or closes the shared writer when one consumer cancels its personal wait. Completion ownership belongs to the component coordinating the producers, while readers own draining and observing terminal failure according to the design. A bounded channel is also not a durable broker, and admission/drop policies must be explicit.
Thread-safe handoff does not automatically supply retries, acknowledgments, process survival, or exactly-once external effects after an item has been accepted or removed.
What a strong answer covers
- Completed admission can coexist with buffered values.
- Terminal outcome must still be observed.
- One wait cancellation does not own shared writer completion.
Common pitfall
Equating no current items with successful producer completion or closing a channel on one reader's cancellation.
Follow-up questions
- Who should complete a writer with multiple producers?
- How does successful empty completion differ from temporary emptiness?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.