title: "Object is currently in use elsewhere" exception when setting image in picturebox
body: <p>With the title, there are several questions but none of them could help me or direct me to solve my problem.</p>
  
  <p>I am building a real-time or near-real-time imaging application with C# winform.</p>
  
  <p>But assigning an image to PictureBox in winform </p>
  
  <pre><code>pictureBox.Image = image; 
  </code></pre>
  
  <p>basically gives a random exception <code>Object is currently in use elsewhere.</code> in 5-20 mins. </p>
  
  <p>I searched materials on this issue but couldn't find a right solution. The error occurred when program was simply setting the image to display from a queue. So there is no way that image can be used in other thread.</p>
  
  <p>At this point, I am not sure winform is right platform for an imaging application. Do I have to move to another platform such as WPF? </p>
  
  <p>I need advice from experienced.</p>
  
  <p><strong>Update:</strong> As Nathanael pointed out, I could access picturebox from multithreads so I assumed that multithreads can access picturebox's image. So when I changed the line above to following, I don't get any error any more.</p>
  
  <pre><code>      private void SetImage(Bitmap image) 
        {
              if (this.pictureBox.InvokeRequired)
              {
                  SetImageCallback callback = new SetImageCallback(SetImage);
                  this.BeginInvoke(callback, new object[] { image });
              }
              else
              {
                  pictureBox.Image = image;
              }
        }
  </code></pre>