Bugs in .NET 2.0 ?

Hi There

Either I'm making an error or there are two bugs I have found in .NET 2.0 Beta ....

privatevoid button2_Click(object sender,EventArgs e)

{

toolStripStatusLabel1.Text ="Asterisk";

toolStripProgressBar1.Value = 33;

System.Media.SystemSounds.Asterisk.Play();

System.Threading.Thread.Sleep(750);


toolStripStatusLabel1.Text =
"Beep";

toolStripProgressBar1.Value = 66;

System.Media.SystemSounds.Beep.Play();

System.Threading.Thread.Sleep(750);


toolStripStatusLabel1.Text =
"Question";

toolStripProgressBar1.Value = 100;

System.Media.SystemSounds.Question.Play();


toolStripProgressBar1.Value = 0;

}

As you can see from the example I am playing some system sounds and updating a status bar and a label.

The first problem is that the status label will not update on the UI after its text property has changed. I have tried .Invalidate and other things but it just won't update.

The second problem is that System.Media.SystemSounds.Question.Play(); does nothing !?!

TIA
Bill

[2045 byte] By [orekin] at [2007-12-16]
# 1
The GUI won't update because you are making the GUI thread sleep. Try moving your process to another thread so that the GUI can update. Warning! You can't update the GUI directly from the other thread. I can give you more info on that if you need it...

On the question of Question.Play() not doing anything, my best guess would be that you don't have a sound associated with a question. That's probably not your problem, but it wouldn't hurt to check.

dkocur2 at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...
# 2
Instead of Thread.Sleep, try Application.DoEvents().
DavidM.Kean at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...
# 3
Aha, Application.DoEvents did the trick:

this.Text = toolStripStatusLabel1.Text = "Asterisk";

toolStripProgressBar1.Value = 20;

Application.DoEvents();

System.Media.SystemSounds.Asterisk.Play();

System.Threading.Thread.Sleep(750);


this
.Text = toolStripStatusLabel1.Text = "Beep";

toolStripProgressBar1.Value = 40;

Application.DoEvents();

System.Media.SystemSounds.Beep.Play();

System.Threading.Thread.Sleep(750);


...although I still think it is a bug with the status bar
Bill
orekin at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...
# 4
Why do you need the Thread.Sleep?
DavidM.Kean at 2007-9-9 > top of Msdn Tech,Visual C#,Visual C# Language...