Пример #1
0
 public void Dispose()
 {
     _mailBox.Complete();
     foreach (var disposable in _cleanup)
     {
         disposable.Dispose();
     }
 }
Пример #2
0
 public void Complete()
 {
     _timeoutBlock.Complete();
     using (ManualResetEvent timerDisposed = new ManualResetEvent(false))
     {
         _timeoutTimer.Dispose(timerDisposed);
         timerDisposed.WaitOne();
     }
 }
Пример #3
0
        private async Task WaitForCompletion()
        {
            _propagationBlock.Complete();
            await _consumerBlock.Completion;

            if (OnTaskCompleted != null)
            {
                await OnTaskCompleted(this, null);
            }
        }
Пример #4
0
        public static AsyncStreamFunc <TInput, TOutput> AsFunction <TInput, TOutput>(this IPropagatorBlock <TInput, TOutput> source, TOutput sentinel = default)
        {
            var wrapper = new AsyncStreamWrapper <TOutput>(source.ReceiveAllAsync(), sentinel);

            return(input => {
                var dummyTask = source.PostAllAsync(input)
                                .ContinueWith(_ => source.Complete());
                return wrapper;
            });
        }
Пример #5
0
 public void Process(string[] inputs)
 {
     if (inputs == null)
     {
         return;
     }
     foreach (var input in inputs)
     {
         _startBlock.Post(input);
     }
     _startBlock.Complete();
 }
Пример #6
0
        public void Complete()
        {
            if (!_block.Completion.IsCompleted)
            {
                _tokenSource.Cancel();

                if (_task.Status != TaskStatus.Created)
                {
                    _task.Wait();
                }

                _block.Complete();
            }
        }
Пример #7
0
        /// <summary>
        /// Posts all items to the given block, upon the full completion of the current one.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="actionBlock">Note: Ensure that you link the block to an output target. There is no automatic null-target block linking.</param>
        public void LinkOnCompleteEx <T>(IPropagatorBlock <TOut, T> actionBlock)
        {
            var standardTransformer = new TransformBlock <TOut, TOut>((doc) =>
            {
                actionBlock.SendAsync(doc).Wait();
                return(doc);
            }, new ExecutionDataflowBlockOptions()
            {
            });

            standardTransformer.Completion.ContinueWith((Task t) =>
            {
                actionBlock.Complete();
            });
            LinkOnComplete(standardTransformer as IPropagatorBlock <TOut, TOut>);
        }
Пример #8
0
        // Demonstrates usage of the sliding window block by sending the provided
        // values to the provided propagator block and printing the output of
        // that block to the console.
        static void DemonstrateSlidingWindow <T>(IPropagatorBlock <T, T[]> slidingWindow,
                                                 IEnumerable <T> values)
        {
            // Create an action block that prints arrays of data to the console.
            string windowComma = string.Empty;
            var    printWindow = new ActionBlock <T[]>(window =>
            {
                Console.Write(windowComma);
                Console.Write("{");

                string comma = string.Empty;
                foreach (T item in window)
                {
                    Console.Write(comma);
                    Console.Write(item);
                    comma = ",";
                }
                Console.Write("}");

                windowComma = ", ";
            });

            // Link the printer block to the sliding window block.
            slidingWindow.LinkTo(printWindow);

            // Set the printer block to the completed state when the sliding window
            // block completes.
            slidingWindow.Completion.ContinueWith(delegate { printWindow.Complete(); });

            // Print an additional newline to the console when the printer block completes.
            var completion = printWindow.Completion.ContinueWith(delegate { Console.WriteLine(); });

            // Post the provided values to the sliding window block and then wait
            // for the sliding window block to complete.
            foreach (T value in values)
            {
                slidingWindow.Post(value);
            }
            slidingWindow.Complete();

            // Wait for the printer to complete and perform its final action.
            completion.Wait();
        }
Пример #9
0
        private static async Task NonSequentialForkAsync()
        {
            IPropagatorBlock <int, string> block =
                CreateMultiTransform <int, string>(UnitOfWorkAsync,
                                                   new ExecutionDataflowBlockOptions
            {
                MaxDegreeOfParallelism = ITERATIONS
            });

            var ab = new ActionBlock <string>(m => Console.WriteLine($"# Action: {m}"));

            block.LinkTo(ab, new DataflowLinkOptions {
                PropagateCompletion = true
            });
            for (int i = 0; i < ITERATIONS; i++)
            {
                block.Post(i);
            }

            block.Complete();
            await ab.Completion.ConfigureAwait(false);

            Console.WriteLine("Done");
        }
Пример #10
0
 /// <summary>
 /// Completes all currently scheduled <see cref="FanArtManagerAction"/>s
 /// and prevents any new actions from being scheduled.
 /// </summary>
 public void Complete()
 {
     _inputBlock.Complete();
 }
Пример #11
0
 public void Complete()
 {
     _batchBlock.Complete();
 }
Пример #12
0
 void IDataflowBlock.Complete()
 {
     transformRightBlock.Complete();
     transformLeftBlock.Complete();
 }
 public void Complete()
 {
     _block.Complete();
 }
        public void Complete_Calls_Underlying_DataFlow_Block_Method()
        {
            _block.Complete();

            _fakeBlock.Verify(b => b.Complete(), Times.Once());
        }
Пример #15
0
 protected override void OnComplete()
 {
     responseBuffer.Complete();
     requestBuffer.Complete();
 }
Пример #16
0
 public void Process(string path)
 {
     first.Post(path);
     first.Complete();
     last.Completion.Wait();
 }
Пример #17
0
 public void Complete()
 {
     _propagatorBlock.Complete();
 }
Пример #18
0
 void IDataflowBlock.Complete()
 {
     output.Complete();
 }
Пример #19
0
 public Task Complete()
 {
     _startBlock.Complete();
     return(Task.CompletedTask);
 }
Пример #20
0
 public void Complete()
 {
     internalBlock.Complete();
 }
Пример #21
0
 /// <summary>
 /// Completes all currently scheduled <see cref="FanArtManagerAction"/>s
 /// and prevents any new actions from being scheduled.
 /// </summary>
 public void Complete()
 {
     _innerBlock.Complete();
 }
 void IDataflowBlock.Complete()
 {
     bufferBlock.Complete();
 }
Пример #23
0
 void IObserver <FormattedLogEvent> .OnCompleted()
 => _bufferBlock.Complete();