It’s common UI courtesy to show the Wait cursor when performing a long operation that requires the user to wait.  Here is how the Wait cursor appears in Windows Vista:

Wait cursor

But developers often go about this the wrong way by setting the Cursor.Current property as follows:

Cursor.Current = Cursors.WaitCursor;

The problem with this approach is it temporarily sets the Wait cursor, but doesn’t ensure that the Wait cursor shows until the end of your operation.  Other programs or controls within your program can easily reset the cursor back to the default arrow:

image

This may confuse the user into thinking the operation has completed when in fact it’s still running.

UseWaitCursor

A much better way to show the Wait cursor is to set the UseWaitCursor property in a form to true:

form.UseWaitCursor = true;

This shows the wait cursor for the specified Form or Control and all its child controls until you set the UseWaitCursor property to false.

If your operation blocks input not just in one window but for your entire application, you can set the Application.UseWaitCursor static property to true:

Application.UseWaitCursor = true;

Note that when you set the Application.UseWaitCursor property, it overrides any settings you made on the UseWaitCursor property for any control or form in your application.

Share and Enjoy:
  • Digg
  • Twitter
  • Facebook
  • Reddit
  • StumbleUpon
  • LinkedIn
  • Google Bookmarks
  • Slashdot