I am writing a simple program to bet on a race by making simple animations with pictures as the racers. My problem is that I don't know how to make a button_click event wait for a timer_tick event. I would rather make it wait before continuing so the user won't accidentally mess up the racing/betting progress. Here is the code with the problem in it.
Code:private void StartRaceButton_Click(object sender, EventArgs e) { this.Enabled = false; timer1.Enabled = true; timer1.Start(); // I need it to wait for the timer to finish here. this.Enabled = true; ChrisRadioButton.Enabled = true; GuestRadioButton.Enabled = true; Guests2RadioButton.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { mustaches[0] = racer1; mustaches[1] = racer2; mustaches[2] = racer3; mustaches[3] = racer4; for ( int r = 0; r <= 3; r++) { bool IsWinner = mustaches[r].Run(); if (IsWinner) { mustaches[r].Winner = true; timer1.Stop(); timer1.Enabled = false; } } }