سؤال

Possible Duplicate:
Why does the async keyword exist

In the C# 5 – await and async combination - I understand the await instruction. But why should I write the async instruction? Shouldn't the compiler be able to automatically detect all async method?

هل كانت مفيدة؟

المحلول

As I stated on my blog, this was considered but rejected.

To summarize: a single-word await keyword would be too big of a breaking change. The choice was between a multi-word await (e.g., await for) or a keyword on the method (async) that would enable the await keyword just within that method. Explicitly marking methods async is easier for both humans and computers to parse, so they decided to go with the async/await pair.

See also Eric Lippert's post, these blog comments, this Channel9 discussion, this forum question, and this SO question.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top