After watching Futurama start to finish for the third or forth time I decided I wanted to try and program up the random number count down generator from episode "A Tale of Two Santas". When I first started this project I only started with displaying one single number at a time, during this step the program appeared to run perfectly. Then I moved onto trying to make my display match the one in the episode with a second delay between each number. After I added code to do this my program doesn't display any number until it hits zero and then closes the program. Instead When I first click my button, it displays "label" for the first second then it cuts it back to "lab" or "la" and half of the letter be until it hits zero. I Have no clues as to why this is happening and would appreciate any input into why this is happening. My code is below.
namespace FuturomaRandomNumberCountDown
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool keepRunning = true; //used for loop kickout
private void start_Click(object sender, EventArgs e)
{
while (keepRunning == true)
{
Random random = new Random((int)DateTime.Now.Ticks);
int randomNum = random.Next(0, 99);
display.Text = Convert.ToString(randomNum);/display number
Thread.Sleep(1000);//delay
if(randomNum==0)//check for zero
{ keepRunning = false; }//to kick out of the while loop
}
Application.Exit();
}
}
}