private void recalculatebutton_Click(object sender, EventArgs e) { if (calculating) { //This means the button has been pressed to stop the computation. progressBar.Visible = false; progressBar.Value = 0; recalculatebutton.Text = "Calculate"; calcLabel.Text = "Analysis terminated."; calculating = false; manager.stopComputation(); } else { //This means the button has been pressed to re-calculate everything. calcLabel.Text = "Calculating results."; progressBar.Visible = true; calcLabel.Visible = true; totalwords.Visible = false; uniquewords.Visible = false; resultsbox.Visible = false; recalculatebutton.Text = "Terminate Calculation"; manager.runBackgroundWorker(false); } }