public static IEnumerable <T> SelectAsParallel <T>(this IEnumerable <T> source, Func <T, T> action)
        {
            if (source.IsNull())
            {
                throw new ArgumentNullException("source");
            }

            if (action.IsNull())
            {
                throw new ArgumentNullException("action");
            }

            return(source.AsParallel().AsOrdered().Select(item => action(item)));
        }
        /// <summary>
        /// Performs the specified <paramref name="action"/> in a parallel, on each element of the <see cref="T:IEnumerable"/>.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of element in the <paramref name="source"/>.</typeparam>
        /// <param name="source">A sequence of elements.</param>
        /// <param name="action">The <see cref="T:Action"/> delegate to perform on each element of the <see cref="T:IEnumerable"/>.</param>
        /// <exception cref="ArgumentNullException">thrown if the <paramref name="source"/> or <paramref name="action"/> is <c>Null</c>.</exception>
        public static void ForEachAsParallel <T>(this IEnumerable <T> source, Action <T> action)
        {
            if (source.IsNull())
            {
                throw new ArgumentNullException("source");
            }

            if (action.IsNull())
            {
                throw new ArgumentNullException("action");
            }

            source.AsParallel().ForAll(item => action(item));
        }
 public static void ForEachParallel <T>(this IEnumerable <T> items, Action <T> action, bool parallel)
 {
     if (parallel)
     {
         Action <T> action2 = action;
         if (ParallelPreAction != null)
         {
             action2 = t => { ParallelPreAction(); action(t); }
         }
         ;
         items.AsParallel().ForAll(action2);
     }
     else
     {
         items.ForEach(action);
     }
 }
 protected void AddRange(IEnumerable <T> items)
 {
     items.AsParallel().ForAll(item => this.Items.Add(item));
 }