Task-Based Asynchronous Pattern (TAP)
The introduction of the Task
type in .NET 4.0 provides for a way to standardize on the object representation of an operation’s eventual completion. In fact, tasks are sometimes referred to as futures, clearly indicating their nature of having a result in the future.
Looking back at the APM, you might wonder whether we don’t already have such a type in the form of the IAsyncResult
interface. Although they share some similarities, a couple of drawbacks apply to using this type when representing futures. One problem is the separation of callbacks from the object representing the operation. Another one is the absence of the operation’s result on the IAsyncResult
object itself. In other words, this type can’t ...
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.