private void CreateOutput(object sender, EventArgs e, int[] years) { try { // create an object to handle communication between // background stuff and progress dialog: _bgworker = HllUtils.MakeWorker( new DoWorkEventHandler(bgworker_DoGenerateWork), new RunWorkerCompletedEventHandler(bgworker_RunWorkerCompleted), new ProgressChangedEventHandler(bgworker_ProgressChanged) ); SetAppState(AppStates.Processing); // create and configure a progress dialog: ProgressForm = new frmProgress(); ProgressForm.Text = Properties.Resources.ProgressGeneratingTitle; ProgressForm.Done = false; ProgressForm.Worker = _bgworker; // Hook up "FormClosed" event handler: ProgressForm.FormClosed += ProgressForm_FormClosed; ProgressForm.Show(); ProgressForm.AddMessage(Properties.Resources.GeneratingOutputFilesMsg); // start the background work: _bgworker.RunWorkerAsync(years); } catch { SetAppState(AppStates.Viewing); if (ProgressForm != null) { ProgressForm.Close(); } throw; } }
private void AddVestaReports(object sender, EventArgs e) { string[] report_names = HllUtils.GetVestaReportNames(); if (report_names != null) { try { // create an object to handle communication between // background stuff and progress dialog: _bgworker = HllUtils.MakeWorker( new DoWorkEventHandler(bgworker_DoImportWork), new RunWorkerCompletedEventHandler(bgworker_RunWorkerCompleted), new ProgressChangedEventHandler(bgworker_ProgressChanged) ); SetAppState(AppStates.Processing); // create and configure a progress dialog: ProgressForm = new frmProgress(); ProgressForm.Text = Properties.Resources.ProgressProcessingReportsTitle; ProgressForm.Done = false; ProgressForm.Worker = _bgworker; // Hook up "FormClosed" event handler: ProgressForm.FormClosed += ProgressForm_FormClosed; ProgressForm.Show(); ProgressForm.AddMessage(Properties.Resources.VestaReportProcessingStartMsg); // start the background work: _bgworker.RunWorkerAsync(report_names); } catch { SetAppState(AppStates.Viewing); if (ProgressForm != null) { ProgressForm.Close(); } throw; } } }