title: Creating a new, temporary Form on a separate thread from the main form using C# and WinForms
body: <p>Having some trouble finding an answer to this specific situation. I need to create a temporary form (that will later be destroyed) that is in a separate thread from the main form. </p>
  
  <p>This form is used for displaying account login information to the user. At the same time this form is on screen, a modal input box is also displayed to the user. The presence of the modal input box prevents any interaction with the login info form (copying/pasting), which is necessary functionality for the user.</p>
  
  <p>How can I:</p>
  
  <p>A) Create and display a new Form on an entirely separate thread from the main Form?</p>
  
  <p>B) Destroy that Form from the main Form's thread once the user has entered input into the modal dialog box?</p>
  
  <p>Note: I have already explored MainForm.Invoke/BeginInvoke and this does not give the results I need, as some other posts have claimed it should.</p>
  
  <p>The code for the modal InputBox:</p>
  
  <pre><code>class InputBox
  {
      public static DialogResult Show(string prompt, bool hideInput, out string userInput, Form parent = null)
      {
          InputBoxForm frm = new InputBoxForm(prompt, hideInput);
  
          if (parent != null)
              frm.ShowDialog(parent);
          else
              frm.ShowDialog();
  
          if (frm.DialogResult == DialogResult.OK)
          {
              userInput = frm.txtInput.Text;
              frm.Dispose();
              return DialogResult.OK;
          }
          else
          {
              userInput = "";
              frm.Dispose();
              return DialogResult.Cancel;
          }
      }
  }
  </code></pre>
  
  <p>And the code as it is used in the program:</p>
  
  <pre><code>Form loginDisplay = LoginInfoForm(user, pass);
  loginDisplay.Show(null);
  string input = "";
  InputBox.Show("Enter info:", false, out input, parent: this);
  </code></pre>
  
  <p>The <code>LoginInfoForm</code> is just a function that dynamically creates a form and formats it a bit.</p>