C# 8中使用IAsyncEnumerable<T>和IAsyncEnumerator<T>,来实现异步迭代(链接)

首先,我们需要知道为什么我们要使用IAsyncEnumerable<T>IAsyncEnumerator<T>来实现异步迭代,它有什么好处?可以参考下面这篇文章:

IAsyncEnumerable In C# 8

其次,关于异步迭代的实现原理和细节,可以参考下面这篇文章:

Iterating with Async Enumerables in C# 8

下面是关于IAsyncEnumerable<T>IAsyncEnumerator<T>接口的微软官方文档:

IAsyncEnumerable<T> Interface

IAsyncEnumerator<T> Interface

原文地址:https://www.cnblogs.com/OpenCoder/p/13354106.html