Hourglass problem in a WinForm application

Actually, there is one more way to do it, which I found somewhere after hours of researching this problem.

Unfortunately, it is a hack.

Below is a method that I wrote that handles the problem.

/// <summary>
    /// Call to toggle between the current cursor and the wait cursor
    /// </summary>
    /// <param name="control">The calling control.</param>
    /// <param name="toggleWaitCursorOn">True for wait cursor, false for default.</param>
    public static void UseWaitCursor(this Control control, bool toggleWaitCursorOn)
    {
        ...

        control.UseWaitCursor = toggleWaitCursorOn;

        // Because of a weird quirk in .NET, just setting UseWaitCursor to false does not work
        // until the cursor's position changes. The following line of code fakes that and 
        // effectively forces the cursor to switch back  from the wait cursor to default.
        if (!toggleWaitCursorOn)
            Cursor.Position = Cursor.Position;
    }

My solution....

public class SetMouseCursor
{
    public static void Wait()
    {
        Application.UseWaitCursor = true;
        Cursor.Current = Cursors.WaitCursor;
    }

    public static void Default()
    {
        Application.UseWaitCursor = false;
        Cursor.Current = Cursors.Default;
    }
}

One more way:

Cursor.Current = Cursors.WaitCursor;

When finished, just change the cursor back:

Cursor.Current = Cursors.Default;

I am unable to reproduce this behaviour? It works fine for me.

One thing to note though if you use the Control.Cursor = Cursors.WaitCursor approach is that it usually used like so:

this.Cursor = Cursors.WaitCursor

Which would appear to work fine, however, this refers the form so if the user moves the mouse to a different control, e.g a TextBox then the mouse does not show the wait cursor.

This may cause confusion for the users. Or could cause some issues if the user continues to work on something else when the Application is busy doing other work.