public void Dispose() { _mailBox.Complete(); foreach (var disposable in _cleanup) { disposable.Dispose(); } }
public void Complete() { _timeoutBlock.Complete(); using (ManualResetEvent timerDisposed = new ManualResetEvent(false)) { _timeoutTimer.Dispose(timerDisposed); timerDisposed.WaitOne(); } }
private async Task WaitForCompletion() { _propagationBlock.Complete(); await _consumerBlock.Completion; if (OnTaskCompleted != null) { await OnTaskCompleted(this, null); } }
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; }); }
public void Process(string[] inputs) { if (inputs == null) { return; } foreach (var input in inputs) { _startBlock.Post(input); } _startBlock.Complete(); }
public void Complete() { if (!_block.Completion.IsCompleted) { _tokenSource.Cancel(); if (_task.Status != TaskStatus.Created) { _task.Wait(); } _block.Complete(); } }
/// <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>); }
// 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(); }
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"); }
/// <summary> /// Completes all currently scheduled <see cref="FanArtManagerAction"/>s /// and prevents any new actions from being scheduled. /// </summary> public void Complete() { _inputBlock.Complete(); }
public void Complete() { _batchBlock.Complete(); }
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()); }
protected override void OnComplete() { responseBuffer.Complete(); requestBuffer.Complete(); }
public void Process(string path) { first.Post(path); first.Complete(); last.Completion.Wait(); }
public void Complete() { _propagatorBlock.Complete(); }
void IDataflowBlock.Complete() { output.Complete(); }
public Task Complete() { _startBlock.Complete(); return(Task.CompletedTask); }
public void Complete() { internalBlock.Complete(); }
/// <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(); }
void IObserver <FormattedLogEvent> .OnCompleted() => _bufferBlock.Complete();