WaitCursor never dies

  • Thread starter Thread starter Tim Johnson
  • Start date Start date
T

Tim Johnson

I'm surrounding some code with a WaitCursor and DefaultCursor call, but in
a number of cases the spinner doesn't go away. I've tried
Application.DoEvents() in various places to no avail. I catch all
exceptions and turn it off there too. This is not easily reproducible but I
get it about half the time in my larger app. Any thoughts on what makes
Cursor.Current = Cursors.DefaultCursor not actually take effect? It stays
spinning all day on my one form; but if I click a button to go to a new form
where I revert to DefaultCursor, it finally goes off. Maddening!

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
Assuming the problem is not changing the cursor from a worker thread, post
some code demonstrating the problem.

Cheers
Daniel
 
I wish I could, but all simplified attempts don't show the behavior. It's
only in my larger app somehow. That's why I was asking more generically if
there is some combination of factors that would make the cursor reset not
"take". I do have worker threads but none play with the cursor, only my
main app.

--

Tim Johnson
High Point Software, Inc.
www.high-point.com
(503) 312-8625
 
I'm having the same problem on a Compact Framework application.

Having been through the code many times, it seems there is nowhere where
the Cursor isn't set back to default, but it occasionally remains which
causes confusion for the user.

When this occurs, the user can provide input to the form on display, and as
soon as the code hits the next "Cursor.Current = Cursors.Default" line, the
wait cursor goes away again!

I've tried using Application.DoEvents to no avail, so I'm a bit stuck as to
what might be causing this problem. One thing I did notice is that the
problem seems more likely to occur if MessageBoxes have been displayed
whilst the wait cursor is active, but this might be a red herring.

Any suggestions would be appreciated!
 
Try re-showing the Cursor before hiding it just afterwards :

Cursor.Current = Cursors.WaitCursor
Cursor.Current = Cursors.Default

It seems kind of stupid, but I had the same problem and finally, that's
how I solved it !


Arthur.
 
Hi Chris,

Are you certain that the line to set the Cursor back to Default always gets
called? I always use try {} finally {} blocks as shown below when setting
Cursors. To ensure that when an exception occurs or I decide to return for
some reason, the Cursor gets set back to default

try {
Cursor.Current = Cursors.Wait;
...
} finally {
Cursor.Current = Cursors.Default;
}

Please post a response if you determine what the solution to your problem
is. It helps us all learn.

Happy Hunting,
Tom
 
Back
Top