コード例 #1
0
 public ChannelBlockEngine(
     Channel <TIn> channel,
     Func <TIn, Task <TOut> > workBodyAsync,
     int maxDegreeOfParallelism,
     bool ensureOrdered,
     TaskScheduler taskScheduler = null,
     CancellationToken token     = default) :
     this(workBodyAsync, maxDegreeOfParallelism, ensureOrdered, taskScheduler)
 {
     _channelBlock = new ChannelBlock <TIn>(channel);
     _channelBlock.LinkTo(_workBlock);
     _channelBlock.StartReadChannel(token);
 }
コード例 #2
0
        public ChannelBlockEngine(
            Func <TIn, Task <TOut> > workBodyAsync,
            int maxDegreeOfParallelism,
            bool ensureOrdered,
            int boundedCapacity         = 1000,
            TaskScheduler taskScheduler = null,
            CancellationToken token     = default) :
            this(workBodyAsync, maxDegreeOfParallelism, ensureOrdered, taskScheduler)
        {
            if (boundedCapacity > 0)
            {
                _channelBlock = new ChannelBlock <TIn>(new BoundedChannelOptions(boundedCapacity));
            }
            else
            {
                _channelBlock = new ChannelBlock <TIn>(new UnboundedChannelOptions());
            }

            _channelBlock.LinkTo(_workBlock);
            _channelBlock.StartReadChannel(token);
        }