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

Declaring Asynchronous Methods

The declaration of an asynchronous method is easy and simply involves adding an async modifier. You can combine this modifier with other modifiers such as static, the accessibility modifiers, and so on. Figure 31.16 shows a couple of valid asynchronous method declarations.

Image

FIGURE 31.16 Asynchronous method declarations.

Notice how an Async suffix is added to the methods to conform with the TAP guidelines. This is merely a convention that isn’t checked by the compiler, but can be checked by code analysis tools.

A few restrictions apply to asynchronous methods. One is the set of allowed return types, restricted to ...

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