title: Parallel.ForEach with conditions
body: <p>I have list of objects. Object is instance of class. Inside each object is property that hold some value:</p>
  
  <pre><code>List&lt;SomeClassTask&gt; lstSomeTaskList = new List&lt;SomeClassTask&gt;();
  
  for (int i=0; i&lt;5; i++)
  {
       SomeClassTask tsk = new SomeClassTask();
       Thread.Sleep(500);
       tsk.SomeProperty = new Random().Next(1, 11);
  
       lstSomeTaskList.Add(tsk);
  }
  </code></pre>
  
  <p>The next step is to run parallel task for each object</p>
  
  <pre><code>Parallel.ForEach(lstSomeTaskList, task =&gt; task.StartProcessing(task.SomeProperty));
  </code></pre>
  
  <p>I want to start only specific tasks like task which has value 1 (SomeProperty = 1).</p>
  
  <p>This is class:</p>
  
  <pre><code>class SomeClassTask
  {
      public int SomeProperty { get; set; }
      public void StartProcessing(int maxRange)
      {
          int rnd = new Random().Next(1, maxRange);
          Thread.Sleep(1000);
          Console.WriteLine("Parallel task -&gt; radnom created value: " + rnd);
      }
  }
  </code></pre>
  
  <p>Is it possible inside </p>
  
  <blockquote>
    <p>Parallel.ForEach</p>
  </blockquote>
  
  <p>put some conditions to check some object properties?</p>