Beispiel #1
0
        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 pipelineFactory = new IncomingPipelineFactory();
            pipelineFactory.Register(() => new DelayStep());
            pipelineFactory.Register(() => new LogStep());
            pipelineFactory.Register(() => new DecrementStep(countdown));

            var strategy = new DequeueStrategy(messages, maxConcurrency: 1);
            await strategy.StartAsync(tm => Connector(pipelineFactory, tm));

            await countdown.WaitAsync();

            await strategy.StopAsync();
        }
Beispiel #2
0
 static Task Connector(IncomingPipelineFactory factory, TransportMessage message)
 {
     var pipeline = factory.Create();
     return pipeline.Invoke(message);
 }