title: Parallel.For statement return "System.InvalidOperationException" with a Bitmap Processing
body: <p>Well, I have a code to apply a Rain Bow filter in "x" image, I have to do in two ways: Sequential &amp; parallel, my sequential code is working without problems, but the parallel section doesn't work. And I have no idea, why?.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>public static Bitmap RainbowFilterParallel(Bitmap bmp)
      {
  
          Bitmap temp = new Bitmap(bmp.Width, bmp.Height);
          int raz = bmp.Height / 4;
  
          Parallel.For(0, bmp.Width, i =&gt;
          {
              Parallel.For(0, bmp.Height, x =&gt;
              {
  
                  if (i &lt; (raz))
                  {
                      temp.SetPixel(i, x, Color.FromArgb(bmp.GetPixel(i, x).R / 5, bmp.GetPixel(i, x).G, bmp.GetPixel(i, x).B));
                  }
                  else if (i &lt; (raz * 2))
                  {
                      temp.SetPixel(i, x, Color.FromArgb(bmp.GetPixel(i, x).R, bmp.GetPixel(i, x).G / 5, bmp.GetPixel(i, x).B));
                  }
                  else if (i &lt; (raz * 3))
                  {
                      temp.SetPixel(i, x, Color.FromArgb(bmp.GetPixel(i, x).R, bmp.GetPixel(i, x).G, bmp.GetPixel(i, x).B / 5));
                  }
                  else if (i &lt; (raz * 4))
                  {
                      temp.SetPixel(i, x, Color.FromArgb(bmp.GetPixel(i, x).R / 5, bmp.GetPixel(i, x).G, bmp.GetPixel(i, x).B / 5));
                  }
                  else
                  {
                      temp.SetPixel(i, x, Color.FromArgb(bmp.GetPixel(i, x).R / 5, bmp.GetPixel(i, x).G / 5, bmp.GetPixel(i, x).B / 5));
                  }
  
              });
  
          });
          return temp;
      }
  </code></pre>
  
  <p>Besides, In a moments the program return the same error but says  "The object is already in use".</p>
  
  <p>PS. I'm beginner with c#, and I Searched this topic in another post and I found nothing.</p>
  
  <p>Thank you very much in advance</p>