O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a TAP Method, Take One

Even though the easiest way to implement TAP methods is by using the new async modifier on a method declaration, we start off by examining a few handcrafted TAP methods. This will clearly illustrate the nature of the Task-based approach to signal the eventual completion of the method’s operation. Later in this chapter, you will learn how to simplify this by using asynchronous methods.

The key aspect to providing a TAP-based method is to return a Task or Task<T> object as soon as possible, which prevents the caller of the method from getting stuck. At a later point in time, this task gets set to let the caller know a result is available. Therefore, there are two sides to a task object: the receiving end (consumer) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required