How to write an “awaitable” method?

后端 未结 6 1895
南笙
南笙 2020-12-07 13:20

I\'m finally looking into the async & await keywords, which I kind of "get", but all the examples I\'ve seen call async methods in the .Net framework, e.g. thi

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 13:30

    Yes, technically you only need to return a Task or Task from an async method to implement an awaitable method.

    This supports the Task-Based Asynchronous Pattern.

    There are several ways of implementing the TAP, however. See Implementing the Task-based Asynchronous Pattern for details.

    (But all these implementations still return Task or Task, of course.)

提交回复
热议问题