using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; class AsyncStreams { async IAsyncEnumerable Items() { yield return 1; yield return 2; await Task.Delay(1000); yield return 3; } async void F() { await foreach(var item in Items()) Console.WriteLine(item); } } namespace System { interface IAsyncDisposable { System.Threading.Tasks.ValueTask DisposeAsync(); } } namespace System.Collections.Generic { interface IAsyncEnumerable { public System.Collections.Generic.IAsyncEnumerator GetAsyncEnumerator (System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } interface IAsyncEnumerator : IAsyncDisposable { T Current { get; } System.Threading.Tasks.ValueTask MoveNextAsync(); } }