title: Closing a form from the Load handler
body: <p>I have a very strange behavior that only seems to happen on one form. </p>
  
  <p>Basically I am creating an instance of a <code>Form</code>, and calling <code>Show()</code> to display the form non-blocking. In that form's <code>Load</code> event handler, I have some logic that may call <code>this.Close()</code> under certain circumstances. This closes the form, but then the form <code>Show()</code> method in the client code throws an <code>ObjectDisposedException</code>.</p>
  
  <p>The stack trace from the ObjectDisposedException is as follows:</p>
  
  <blockquote>
    <p>at System.Windows.Forms.Control.CreateHandle()<br>
      at System.Windows.Forms.Form.CreateHandle()<br>
      at System.Windows.Forms.Control.get_Handle()<br>
      at System.Windows.Forms.ContainerControl.FocusActiveControlInternal()<br>
      at System.Windows.Forms.Form.SetVisibleCore(Boolean value)<br>
      at System.Windows.Forms.Control.Show()<br>
     ...etc.</p>
  </blockquote>
  
  <p>This is what I'm seeing happen:</p>
  
  <ol>
  <li><code>Control.Show()</code> is called</li>
  <li>my form is launched</li>
  <li>the <code>OnFormLoad</code> method is called</li>
  <li>the <code>FormLoad</code> event handler is called, inside of which I call <code>this.Close()</code></li>
  <li>the <code>OnFormClosing</code> method is called</li>
  <li>the <code>FormClosing</code> event handler is called</li>
  <li><code>Dispose</code> is called on my form and all it's user controls</li>
  </ol>
  
  <p>and then somewhere toward the end of the <code>Control.Show()</code> method, it tries to get a handle to the form, which freaks out and throws an exception because the object is marked disposed.</p>
  
  <p>My real question is, why can I do this exact same thing on every other form I have without exceptions? Is it a GC issue? I've tried putting a <code>GC.Collect()</code> call right after the <code>this.Close()</code> and it makes no difference. Like I said, it happens 100% of the time on this form, and never anywhere else, regardless of child user controls, scope of the form variable, etc.</p>
  
  <p>Any ideas?</p>