/// <summary>Runs the query and outputs its results into the target collection.</summary> /// <typeparam name="TSource">Specifies the type of elements output from the query.</typeparam> /// <param name="source">The source query.</param> /// <param name="target">The target collection.</param> public static void OutputToProducerConsumerCollection <TSource>(this ParallelQuery <TSource> source, IProducerConsumerCollection <TSource> target) { if (source == null) { throw new ArgumentNullException("source"); } if (target == null) { throw new ArgumentNullException("target"); } source.ForAll <TSource>(item => target.TryAdd(item)); }
/// <summary>Runs the query and outputs its results into the target collection.</summary> /// <typeparam name="TSource">Specifies the type of elements output from the query.</typeparam> /// <param name="source">The source query.</param> /// <param name="target">The target collection.</param> public static void OutputToProducerConsumerCollection <TSource>( this ParallelQuery <TSource> source, IProducerConsumerCollection <TSource> target) { // Validate arguments if (source == null) { throw new ArgumentNullException("source"); } if (target == null) { throw new ArgumentNullException("target"); } // Store all results into the collection source.ForAll(item => target.TryAdd(item)); }