J
John Salerno
I was reading the "thread problem" post and maybe it has something to do
with this, but I didn't quite understand it all. Here is the code I wrote:
private void btnStart_Click(object sender, EventArgs e)
{
int time = Int32.Parse(txtTime.Text);
Thread.Sleep(60000);
for (int i = time - 1; i > 0; i--)
{
txtMessage.Text = i + " minutes remaining.";
Thread.Sleep(60000);
}
txtMessage.Text = time + " minutes have elapsed.";
for (int i = 3; i > 0; i--)
{
Console.Beep();
Thread.Sleep(1000);
}
Originally this was a console application, and I just changed the
txtMessage.Text parts from the original Console.WriteLine parts.
What happens is that it will run through to the end (although sometimes
I get "Not Responding") and it will display the final message and the
beeps, but it does not run through the first for loop, which shows
minutes remaining. The debugger also seems to get hung up when I use it,
and I can't find a way to step over the Thread.Sleep method, so it sort
of kills the application, even in debug mode.
with this, but I didn't quite understand it all. Here is the code I wrote:
private void btnStart_Click(object sender, EventArgs e)
{
int time = Int32.Parse(txtTime.Text);
Thread.Sleep(60000);
for (int i = time - 1; i > 0; i--)
{
txtMessage.Text = i + " minutes remaining.";
Thread.Sleep(60000);
}
txtMessage.Text = time + " minutes have elapsed.";
for (int i = 3; i > 0; i--)
{
Console.Beep();
Thread.Sleep(1000);
}
Originally this was a console application, and I just changed the
txtMessage.Text parts from the original Console.WriteLine parts.
What happens is that it will run through to the end (although sometimes
I get "Not Responding") and it will display the final message and the
beeps, but it does not run through the first for loop, which shows
minutes remaining. The debugger also seems to get hung up when I use it,
and I can't find a way to step over the Thread.Sleep method, so it sort
of kills the application, even in debug mode.