Exemplo n.º 1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            if (Utils.checkAllDataLoaded(gridsList))
            {
                // Create a background thread
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += new DoWorkEventHandler(bw_DoWork);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

                // Create a progress form on the UI thread
                frmProgress = new ProgressBarForm();

                // Initialize progress bar properties
                frmProgress.progressBar.Maximum = Globals.ITERATIONS_NUM_VALUE;
                frmProgress.progressBar.Step = 100 / Globals.ITERATIONS_NUM_VALUE;

                // Kick off the Async thread
                bw.RunWorkerAsync();

                // Lock up the UI with this modal progress form.
                tabCommon.SelectedTab = tabGeneral;
                frmProgress.ShowDialog(this);
                frmProgress = null;
            }
            else
            {
                MessageBox.Show("Check that all data in tabs were successfully loaded!");
            }
        }
Exemplo n.º 2
0
        private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (frmProgress != null)
            {
                frmProgress.Hide();
                frmProgress = null;
            }

            if (e.Error != null)
            {
                MessageBox.Show(e.Error.Message);
                return;
            }

            // Check to see if the background process was cancelled.
            if (e.Cancelled)
            {
                lblState.Text = "STATUS: Canceled!";
                MessageBox.Show("Processing cancelled.");
                return;
            }

            // Everything completed normally.
            lblState.Text = "STATUS: Completed!";
            lblOutput.Text = "'" + Globals.OUTPUT_FILE_NAME_PREFIX + "-" + callsFileName + "'";
            lblOutput.Visible = true;
            btnViewResult.Visible = true;
            MessageBox.Show("Processing is complete.");
        }