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

No Asynchronous Main Method?

One key property of asynchronous methods is their early return while work is carried out. The returned Task or Task<T> object is used to track the completion of the operation, which is usually done using an await expression. To use an await expression, the containing method has to be declared as asynchronous as well. You may wonder what happens if asynchrony continues to spread up the invocation chain, all the way to the Main method. Figure 31.28 shows the error message that results when trying to mark the Main method as asynchronous.

Image

FIGURE 31.28 Compiler error when marking Main as async.

When you think about it, ...

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