private void ThreadedExportPlanetPositions() { Action exec = ExportPlanetPositions; BlockingProgressBar bpb = new BlockingProgressBar(); BackgroundWorker exporter = new BackgroundWorker(); exporter.DoWork += (object sender, DoWorkEventArgs e) => { System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; exec.Invoke(); }; exporter.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) => { if (bpb != null && bpb.Visible) { Enabled = true; bpb.Close(); bpb.Dispose(); } }; Enabled = false; bpb.StartPosition = FormStartPosition.Manual; bpb.Location = new Point(Location.X + (Width - bpb.Width) / 2, Location.Y + (Height - bpb.Height) / 2); bpb.Show(this); exporter.RunWorkerAsync(); }
private void ThreadedParseFiles() { Action exec = ParseXMLFiles; BlockingProgressBar bpb = new BlockingProgressBar(); BackgroundWorker parser = new BackgroundWorker(); parser.DoWork += (object sender, DoWorkEventArgs e) => { System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; exec.Invoke(); }; parser.RunWorkerCompleted += (object sender, RunWorkerCompletedEventArgs e) => { if (bpb != null && bpb.Visible) { planet_placement_project_.ProjScaleSetting = tool.Global.PROJECT_SCALE_; Project_Scale_.Maximum = tool.Global.PROJECT_MAX_SCALE_; Project_Scale_.Minimum = tool.Global.PROJECT_MIN_SCALE_; Project_Scale_.Value = tool.Global.Clamp(tool.Global.PROJECT_SCALE_, tool.Global.PROJECT_MAX_SCALE_, tool.Global.PROJECT_MIN_SCALE_); Populate_Planet_Display(); DrawAllPlanets(); Save(); main_status_strip_label01_.Text = "Loaded project: " + project_save_folder_ + "\\" + planet_placement_project_.ProjectName + ".yvaw-pptp"; tool.Global.PROJECT_INITIALISED_ = true; Enabled = true; bpb.Close(); bpb.Dispose(); } }; this.Enabled = false; bpb.StartPosition = FormStartPosition.Manual; bpb.Location = new Point(Location.X + (Width - bpb.Width) / 2, Location.Y + (Height - bpb.Height) / 2); bpb.Show(this); parser.RunWorkerAsync(); }