public ChooseTarget(ChooserBlock <T1, T2, T3> chooserBlock, int index, Action <TMessage> action) { this.chooserBlock = chooserBlock; this.index = index; this.action = action; }
public static Task<int> Choose<T1, T2, T3> ( ISourceBlock<T1> source1, Action<T1> action1, ISourceBlock<T2> source2, Action<T2> action2, ISourceBlock<T3> source3, Action<T3> action3, DataflowBlockOptions dataflowBlockOptions) { if (source1 == null) throw new ArgumentNullException ("source1"); if (source2 == null) throw new ArgumentNullException ("source2"); if (source3 == null) throw new ArgumentNullException ("source3"); if (action1 == null) throw new ArgumentNullException ("action1"); if (action2 == null) throw new ArgumentNullException ("action2"); if (action3 == null) throw new ArgumentNullException ("action3"); if (dataflowBlockOptions == null) throw new ArgumentNullException ("dataflowBlockOptions"); var chooser = new ChooserBlock<T1, T2, T3> (action1, action2, action3, dataflowBlockOptions); source1.LinkTo (chooser.Target1); source2.LinkTo (chooser.Target2); source3.LinkTo (chooser.Target3); Task.WhenAll (source1.Completion, source2.Completion, source3.Completion) .ContinueWith (_ => chooser.AllSourcesCompleted ()); return chooser.Completion; }