title: When is the window handle created
body: <p>I thought my code was safe, but it is not.</p>
  
  <p>I am using a form to display some messages that are created and managed somewhere else in my app.</p>
  
  <p>To get to this message I am using a delegate that I add to my external event in the <code>form.load</code> event.</p>
  
  <pre><code>private void ErrorLog_Load( object sender, EventArgs e )
  {
      //error handler has been properly initialized in the ctor
      Handler.getInstance( ).errorOccured += errorHandler;
  }
  </code></pre>
  
  <p>I the callback of the form I need to invoke:</p>
  
  <pre><code>protected void handleError( SenderInfo sender, ErrorEventArgument argument )
  {
      if (this.InvokeRequired)
      {
          this.Invoke(errorHandler, new object[] { sender, argument });
      }
      else
      {
         //update the form
      }
  }
  </code></pre>
  
  <p>And in the closed/ closing event the callback is unregistered.</p>
  
  <p>Now I have a situation where the window is created as an mdi child an obviously not shown (hidden by another mdi window) and the app crashes in handleError at the line with Invoke with the message that the window handle has not been created.</p>
  
  <p>So three questions:
  At which point in time is the window handle of the form created
  Appart from adding <code>this.IsHandleCreated</code> to my <code>handleError</code> how should I improve my code
  What is the correct event to unregister the callback?</p>
  
  <p>TIA</p>
  
  <p>Mario</p>