- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我听说 awaitable 是一种异步操作。但是既然是一个重要的概念,为什么我在 MSDN 上找不到准确的定义呢?
我的问题不是如何编写 async/await。我的问题是了解这个概念。 MSDN有概念async/await
但没有 awaitable
.
那么什么是可等待的呢?如果是手术,包括什么?
最佳答案
最后我在 Async/Await FAQ. 上找到了它
An “awaitable” is any type that exposes a GetAwaiter method which returns a valid “awaiter”. This GetAwaiter method may be an instance method (as it is in the case of Task and Task<TResult>), or it may be an extension method.
An “awaiter” is any type returned from an awaitable’s GetAwaiter method and that conforms to a particular pattern. The awaiter must implement the System.Runtime.CompilerServices.INotifyCompletion interface, and optionally may implement the System.Runtime.CompilerServices.ICriticalNotifyCompletion interface. In addition to providing an implementation of the OnCompleted method that comes from INotifyCompletion (and optionally the UnsafeOnCompleted method that comes from ICriticalNotifyCompletion), an awaiter must also provide an IsCompleted Boolean property, as well as a parameterless GetResult method. GetResult returns void if the awaitable represents a void-returning operation, or it returns a TResult if the awaitable represents a TResult-returning operation.
关于.net - 什么值得期待?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40853158/
我正在生成代码,其中我恰好将 n 个单词从一个内存位置复制到另一个非重叠内存位置。 n 是静态已知的。 目前,我发出大量加载指令,然后是大量存储指令,但我怀疑从 n 的某个值开始,调用 memcpy会
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
用例如下: 我有一张 map ,其中将插入一些键/值。 该程序将查询该 map ,但是在第一个查询之后,我可以保证该 map 将完全不会被修改。 因为查询的结果完全是输入的函数,所以在查询方法上放置属
Helo 伙计们,我尝试使用 Refs 并在他的内部提供 this.setState 但它给出: Maximum update depth exceeded. This can happen when
在检查事件时,使用带有 switch 或 if 的代码块是很常见的事情。如果变得简单,它可以是干净的代码,但似乎仍然有比需要更多的行,并且可以使用 lambda 进行简化。 用 if 阻止: if(a
Amazon 最近宣布在其 RDS 产品线中支持 Oracle: http://aws.amazon.com/rds/oracle/ 我想知道是否有人使用过它,或者是否有令人信服的理由将我的数据从 M
我是一名优秀的程序员,十分优秀!