public void Async() { var pp = new PublishProcessor <int>(); pp.Start(); Task.Factory.StartNew(() => { while (!pp.HasSubscribers) { Thread.Sleep(10); } for (int i = 0; i < 5; i++) { while (!pp.Offer(i)) { ; } } pp.OnComplete(); }, TaskCreationOptions.LongRunning); pp.Test().AwaitDone(TimeSpan.FromSeconds(5)) .AssertResult(0, 1, 2, 3, 4); }
public override IPublisher <int> CreatePublisher(long elements) { var pp = new PublishProcessor <int>(); pp.Start(); Task.Factory.StartNew(() => { while (!pp.HasSubscribers) { Thread.Sleep(10); } for (int i = 0; i < elements; i++) { while (!pp.Offer(i)) { ; } } pp.OnComplete(); }, TaskCreationOptions.LongRunning); return(pp); }