title: Form.Show() causes an InvalidOperationException in visual studio 2010 that was not there in 2008
body: <p>I have some code that takes a form object (winforms) and calls form.Show() on a dedicated thread (it spins a new thread).
  This worked fine in Visual Studio 2008 (framework 3.5). I now migrated to 2010 and it fails with
  InvalodOperationException: "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."</p>
  
  <p>(of course half our files are checked out for the migration and the whole team is waiting...)</p>
  
  <p>Here is some code (this is the running code so fogive me for some redundant level of detail):</p>
  
  <pre><code>    private void ShowForm(object container)
      {
          FormContainer formContainer = (FormContainer)container;
          Process sboProcess = GetSboProcess();
          if (sboProcess != null)
          {
              WindowWrapper MyWindow = new WindowWrapper(sboProcess.MainWindowHandle);
              if (formContainer.ShowDialog)
              {
                  formContainer.Form.ShowDialog(MyWindow);
              }
              else
              {
                  //formContainer.Form.Invoke((MethodInvoker)delegate() { formContainer.Form.Show(MyWindow); });
                  formContainer.Form.Show(MyWindow);
                  //Run thread while form is opened:
                  System.Windows.Forms.Application.Run(formContainer.Form);
              }
          }
      }
  
  
  
  public class FormContainer
  {
      private readonly Form form;
      private readonly bool showDialog;
  
      public FormContainer(Form form, bool showDialog)
      {
          this.form = form;
          this.showDialog = showDialog;
      }
  
      public bool ShowDialog
      {
          get { return showDialog; }
      }
  
      public Form Form
      {
          get { return form; }
      }
  
  }
  
   public class WindowWrapper : IWin32Window
  {
      private readonly IntPtr handle;
  
      public WindowWrapper(IntPtr handle)
      {
          this.handle = handle;
      }
  
      #region Implementation of IWin32Window
  
      /// &lt;summary&gt;
      ///                     Gets the handle to the window represented by the implementer.
      /// &lt;/summary&gt;
      /// &lt;returns&gt;
      ///                     A handle to the window represented by the implementer.
      /// &lt;/returns&gt;
      /// &lt;filterpriority&gt;1&lt;/filterpriority&gt;
      public IntPtr Handle
      {
          get { return handle; }
      }
  
      #endregion
  }
  </code></pre>
  
  <p>Anyone with an idea?</p>
  
  <p>Thanks,</p>
  
  <p>Asher</p>