The State Machine Fueling Asynchronous Methods
When an asynchronous method executes, it may come across one or more await
expressions. At that point in time, a dialogue is started with the object being awaited. This object is commonly referred to as the task, even though it doesn’t necessarily have to be a Task
or Task<T>
instance. We discuss the await pattern later on, also explaining how other types can be made awaitable.
What happens upon encountering a task being awaited depends on the current state of the task. Maybe the operation it represents has already been completed, allowing us to continue to execute the current method. However, most likely we’ll be unlucky and truly need to await the operation’s outcome before we can continue execution ...
Get C# 5.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.