title: Dispose form after closing
body: <p>I have got the new problem with opening and closing form in C#.</p>
  
  <p>My problem is how to dispose the form after closing .</p>
  
  <p>here is my code : </p>
  
  <p>Program.cs:</p>
  
  <pre><code>static class Program
  {
      public static Timer timer;
  
      [STAThread]
      static void Main()
      {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
  
          timer = new Timer { Interval = 1000};
          timer.Start();
  
          Application.Run(new Form1());
      }
  }
  </code></pre>
  
  <p>Form1.cs:</p>
  
  <pre><code>public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          Form2 form = new Form2();
          form.ShowDialog();
         /// I've tried Dispose() method . but didn't work
      }
  }
  </code></pre>
  
  <p>Form2.cs:</p>
  
  <pre><code>public partial class Form2 : Form
  {
      public Form2()
      {
          InitializeComponent();
      }
  
      private void Form2_Load(object sender, EventArgs e)
      {
          Program.timer.Tick += timer_Tick;    
          Close();
          // I've tried Dispose() method instead of Close() but didn't work
      }
  
      private int count = 0; 
      void timer_Tick(object sender, EventArgs e)
      {
          count++;
          if (count == 5) MessageBox.Show("");
      }
  }
  </code></pre>
  
  <p><strong>Edited :</strong>
  My question is : why the message box shows after 5 seconds when the form2 has closed! </p>