public async Task Do() { var messages = new ConcurrentQueue <TransportMessage>(); messages.Enqueue(new TransportMessage()); messages.Enqueue(new TransportMessage()); messages.Enqueue(new TransportMessage()); var countdown = new AsyncCountdownEvent(3); var chainFactory = new ChainFactory(); chainFactory.Register(() => new SignalElement(countdown)); chainFactory.Register(() => new SwallowElement()); chainFactory.Register(() => new DelayPhysicalBefore()); chainFactory.Register(() => new DelayPhysicalAfter()); chainFactory.Register(() => new DelayPhysicalBefore()); chainFactory.Register(() => new DelayPhysicalAfter()); chainFactory.Register(() => new DelayPhysicalBefore()); chainFactory.Register(() => new DelayPhysicalAfter()); chainFactory.Register(() => new DelayPhysicalBefore()); chainFactory.Register(() => new DelayPhysicalAfter()); chainFactory.Register(() => new LogPhysical()); chainFactory.Register(() => new PhysicalToLogicalConnector()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new DelayLogicalBefore()); chainFactory.Register(() => new DelayLogicalAfter()); chainFactory.Register(() => new LogLogical()); chainFactory.Register(() => new ThrowElement()); var pushMessages = new PushMessages(messages, maxConcurrency: 1); await pushMessages.StartAsync(tm => Connector(chainFactory, tm)); await countdown.WaitAsync(); await pushMessages.StopAsync(); }