ChannelUtils/Extensions.cs
/// <summary>
/// Merging all data from <see cref="inputs"/> to new one
/// </summary>
/// <param name="inputs"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
Merging all data from  to new one
Merging all data from to new one
public static ChannelReader<T> Merge<T>(this ChannelReader<T>[] inputs)
		{
			var output = Channel.CreateUnbounded<T>();
			Task.Run(async () =>
			{
				async Task RedirectLocal(ChannelReader<T> input)
				{
					while (await input.WaitToReadAsync())
					{
						if (!input.TryRead(out var channelData)) continue;
						await output.Writer.WriteAsync(channelData);
					}
				}
				await Task.WhenAll(inputs.Select(RedirectLocal).ToArray());
				output.Writer.Complete();
			});
			return output.Reader;
		}
public static ChannelReader < T > Merge < T > ( this ChannelReader < T > [ ] inputs ) { var output = Channel . CreateUnbounded < T > ( ) ; Task . Run ( async ( ) => { async Task RedirectLocal ( ChannelReader < T > input ) { while ( await input . WaitToReadAsync ( ) ) { if ( ! input . TryRead ( out var channelData ) ) continue ; await output . Writer . WriteAsync ( channelData ) ; } } await Task . WhenAll ( inputs . Select ( RedirectLocal ) . ToArray ( ) ) ; output . Writer . Complete ( ) ; } ) ; return output . Reader ; }
Merging all data from  to new one
Merging all data from to new one
None
ChannelReader<T>[]
this
inputs
None
typeparam
None