ChannelUtils/Extensions.cs
/// <summary>
/// Create channel and send all <see cref="data"/> into the channel
/// </summary>
/// <param name="data"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
Create channel and send all  into the channel
Create channel and send all into the channel
public static ChannelReader<T> Create<T>(this IEnumerable<T> data)
		{
			var ch = Channel.CreateUnbounded<T>(new UnboundedChannelOptions
			{
				AllowSynchronousContinuations = true
			});
			Task.Run(async () =>
			{
				foreach (var item in data)
				{
					await ch.Writer.WriteAsync(item);
				}
				ch.Writer.Complete();
			});
			return ch.Reader;
		}
public static ChannelReader < T > Create < T > ( this IEnumerable < T > data ) { var ch = Channel . CreateUnbounded < T > ( new UnboundedChannelOptions { AllowSynchronousContinuations = true } ) ; Task . Run ( async ( ) => { foreach ( var item in data ) { await ch . Writer . WriteAsync ( item ) ; } ch . Writer . Complete ( ) ; } ) ; return ch . Reader ; }
Create channel and send all  into the channel
Create channel and send all into the channel
None
IEnumerable<T>
this
data
None
typeparam
None