private static async Task ListenToQueue(ChannelQueue <PersonProper> channel, CancellationToken token) { await foreach (var item in channel.ListenAsync(token)) { Trace.WriteLine(item.Email); } }
public async Task WriteReadAsyncTest03() { var channel = new ChannelQueue <PersonProper>(); const int Count = 5; var people = RandomData.GeneratePersonRefCollection <PersonProper>(Count); var token = CancellationToken.None; foreach (var person in people) { await channel.WriteAsync(person, cancellationToken : token).ConfigureAwait(false); } Assert.IsTrue(channel.Count == Count); _ = channel.Lock(); await foreach (var item in channel.ListenAsync(token)) { Trace.WriteLine(item.Email); } Assert.IsTrue(channel.Count == 0); }