C# で GIS アプリケーションを作成しています。アプリケーションの一部で、ユーザーは KML ファイルを選択でき、プログラムはそのファイルを処理します。を使用してOpenFileDialog
いますが、問題は、ダイアログが閉じられる前に (およびユーザーがファイルを OK した後に) すべてのコードが実行されることです。プログラムはズームや他のことをしなければならないので、かなり時間がかかります。コードが実行される前にプログラムでダイアログを閉じる方法はありますか?
編集:尋ねる人のためのいくつかのコード。
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());
}