Link to home
Start Free TrialLog in
Avatar of PiedBird
PiedBird

asked on

view hourglass with UseWaitCursor

Hi
using code: Me.UseWaitCursor = true
I can set the mouse pointer on my form to an hourglass. I run this code on a CheckedChanged event of a checkbox. The problem is the hourglass doesn't appear on my screen until all the code in this procedure is finished (the code goes on to try opening a serial port). How do I ensure the hourglass is viewed on my form before the remaining code in the procedure runs?
Thanks
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Hi PiedBird;

After the statement to set the pointer to an hourglass the next statement try putting the following.

    Application.DoEvents()

Fernando
Avatar of PiedBird
PiedBird

ASKER

Hello Fernando

Ok
No result.

Here is the code
        Me.UseWaitCursor = True
        Application.DoEvents()
        OpenOrCloseSP2()
        MsgBox("done")
        'Me.UseWaitCursor = False

I put the message box in to see when the pointer changed: ie before or after the messagebox. It changed afterwards!
Hi PiedBird;

I think that there might be a bug. If you leave the Application.DoEvents in and run the program and then move the Window while the procedure is running the cursor will change.

Fernando
   Hi Fernando,
I put this procedure on a new form in a new application.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Application.UseWaitCursor = True
        Label1.Text = "processing"
        Application.DoEvents()
        Dim int As Double = 999999999
        Do Until int = 0
            int -= 1
        Loop
        Label1.Text = "done"
        Application.UseWaitCursor = False

    End Sub

I had trouble moving the window while the procedure was running but after a few seconds it moved and your prediction was correct. However the label text changed when it should (but not without "application.DoEvents()" thankyou).

Have you any more suggestions?

PiedBird
       
SOLUTION
Avatar of iboutchkine
iboutchkine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thankyou both.

I maybe should be more forceful in communicating with my machine. Instead of me unobtrusively changing a cursor property and expecting the machine to immediately notice, I should take an approach like, "Oy! Change your cursor!"

Happy regards,
Pied Bird
I have the same problem some times, LOL. Glad I was able to help with iboutchkine. ;=)