Sometimes Application.DoEvents() or this.Refresh() works as intended.
(this->form)
Tom wrote:
> I am having troble changing the cursor into an hour glass. In this
> code, when you click the "hour glass" button, the cursor changes into
> an hourglass. When you click the "normal" button, the cursor returns
> to normal.
>
> private void button1_Click(object sender, EventArgs e)
> {
> Application.UseWaitCursor = true;
> }
>
> private void button2_Click(object sender, EventArgs e)
> {
> Application.UseWaitCursor = false;
> }
>
> In this code, the cursor does not turn into an hourglass until after
> the program finishes the for loop. How do I get the cursor to change
> into an hourglass immediately after the command
> Application.UseWaitCursor = true? Am I using the wrong command?
>
> private void button1_Click(object sender, EventArgs e)
> {
> Application.UseWaitCursor = true;
> MessageBox.Show("Max value for a int " +
> int.MaxValue.ToString());
> for (int x=0; x < int.MaxValue; x++)
> ;
> }
>
> private void button2_Click(object sender, EventArgs e)
> {
> Application.UseWaitCursor = false;
> }
>
> Thanks in advance for you help.