title: Force dialog close in C#
body: <p>I'm writing a GIS application in C#. A portion of the application allows the user to select a KML file, and then the program will process that file. I'm using an <code>OpenFileDialog</code>, but the problem is that all of the code is executed before the dialog gets closed (and after the user has OK'd the file). It takes quite awhile because the program has to zoom and do other things. Is there a way to close the dialog programmatically before my code is executed?</p>
  
  <p>EDIT: Some code for those who ask.</p>
  
  <pre><code>private void OnKMLFileSet(object sender, CancelEventArgs e)
  {
      Polygon polygon = KmlToPolygon(openFileDialog2.FileName);
      // After this, I no longer need the file, but the dialog stays open until the end of the method
      Graphic graphic = new Graphic();
      graphic.Geometry = polygon;
      textBox1.Text = string.Format("{0:n}", CalculateAreaInSqKilometers(polygon)).Split('.')[0];
      textBox2.Text = string.Format("{0:n}", CalculateAreaInSqMiles(polygon)).Split('.')[0];
      textBox3.Text = string.Format("{0:n}", CalculateAreaInSqKnots(polygon)).Split('.')[0];
      Note polyInfo = new Note("Polygon with nautical area: " + textBox3.Text, polygon);
      map.Map.ChildItems.Add(polyInfo);
      map.ZoomTo(polygon.GetEnvelope());
  }
  </code></pre>