private void button_Click(object sender, EventArgs e) { Main main = Main.Get(); if (main.InBenchmarkInProgress()) { main.CancelBenchmark(); this.Close(); } else if (this.button.Text == "Start Benchmark") { this.button.Text = "Cancel Benchmark"; main.Benchmark(); } else { this.Close(); } }