Example #1
0
 protected NamedProducerConsumerThreadQueue([NotNull] ProducerConsumerQueueOptions <T> options, CancellationToken token = default(CancellationToken))
     : base(options, token)
 {
     if (options is not ProducerConsumerThreadNamedQueueOptions <T> namedQueueOptions)
     {
         return;
     }
     Name = namedQueueOptions.Name;
 }
Example #2
0
 protected ProducerConsumerQueue([NotNull] ProducerConsumerQueueOptions <T> options, CancellationToken token = default(CancellationToken))
 {
     Threads           = options.Threads;
     ExecuteCallback   = options.ExecuteCallback;
     ResultCallback    = options.ResultCallback;
     ScheduledCallback = options.ScheduledCallback;
     FinalizeCallback  = options.FinalizeCallback;
     _cts = new CancellationTokenSource();
     if (token.CanBeCanceled)
     {
         token.Register(() => _cts.CancelIfNotDisposed());
     }
     Token = _cts.Token;
 }
Example #3
0
 protected ProducerConsumerThreadQueue([NotNull] ProducerConsumerQueueOptions <T> options, CancellationToken token = default(CancellationToken))
     : base(options, token)
 {
     if (options is ProducerConsumerThreadQueueOptions <T> threadQueueOptions)
     {
         IsBackground = threadQueueOptions.IsBackground;
         Priority     = threadQueueOptions.Priority;
     }
     else
     {
         IsBackground = true;
         Priority     = ThreadPriority.Normal;
     }
 }
 protected ProducerConsumerThresholdQueue([NotNull] ProducerConsumerQueueOptions <T> options, CancellationToken token = default(CancellationToken))
     : base(options, token)
 {
     Threshold    = options is ProducerConsumerThresholdQueueOptions <T> thresholdQueueOptions ? thresholdQueueOptions.Threshold : TimeSpan.Zero;
     HasThreshold = Threshold > TimeSpan.Zero;
 }