private static async AsyncSequence <int> Test2() { var yield = await AsyncSequence <int> .Capture(); await Task.Delay(0).ConfigureAwait(false); for (var i = 1; i <= 3; i++) { yield.Return(i); } return(yield.Break()); }
public static async AsyncSequence <int> Producer2() { var seq = await AsyncSequence <int> .Capture(); // Capture the underlying 'Task' for (int i = 1; i <= 5; i++) { await Task.Delay(100).ConfigureAwait(false); // Use any async constructs seq.Return(i); // Return to an awaiting MoveNext, or queue the result. } return(seq.Break()); // Returns false to awaiting MoveNext }
private static async AsyncSequence <int> Test1() { var yield = await AsyncSequence <int> .Capture(); await Task.Delay(0).ConfigureAwait(false); yield.Return(1); yield.Return(2); yield.Return(3); return(yield.Break()); }