Core.ActForEach - Dmitry-Bychenko/Amphisbaena GitHub Wiki
Copies input into output while executing action on each item in reader whenever condition meets
public static ChannelReader<T> ActForEach<T>(this ChannelReader<T> reader,
Action<T, long> action,
Func<T, long, bool> condition,
ChannelParallelOptions options)using Amphisbaena;
using Amphisbaena.Linq;
...
int[] data = new int[] {1, 2, 3, -1, 4, 5};
int sum = data
.ToChannelReader()
.ActForEach((item, index) => Console.WriteLine($"Negative item {item} at {index}!"),
(item, index) => item < 0)
.Aggregate((s, a) => s + a);