title: Singleton modal dialog
body: <p>Is it possibile to create a modal dialog form following the singleton pattern?</p>
  
  <p>The idea is:</p>
  
  <pre><code>public partial class Singleton : Form
  {
      private static Singleton _instance = null;
  
      private Singleton()
      {
          // Initialization code
      }
  
      public static Singleton Instance
      {
          get
          {
              if (_instance == null)
                  _instance = new Singleton();
  
              return _instance;
          }
      }
  
      private void Singleton_FormClosing(object sender, FormClosingEventArgs e)
      {
          _instance.Hide();
          e.Cancel = true;
      }
  
      private void buttonClose_Click(object sender, EventArgs e)
      {
          this.Close();
      }
  }
  </code></pre>
  
  <p>This code works fine if the form is non-modal (so, if the Show() method is used), but does not work if the form is modal (so, if the ShowDialog() method is used) because this will also hide the parent form.</p>