By Fons Sonnemans, 10-2-2005

For a long time I thought that I only had to set the Cursor.Current to a WaitCursor before a long running operation, the .NET runtime would reset it back to the Default cursor. Turns out that this is only true when the mouse is moved. Bummer.

// Cursor.Current are automatically reset to Default when the
// mouse is moved and the application is idle!
Cursor.Current = Cursors.WaitCursor;

The solution for this problem is very easy. I created a helper class called WaitCursor which set the Cursor.Current and restores it to the original value when it it disposed.

public sealed class WaitCursor : IDisposable {                
    private Cursor _prev;

    public WaitCursor() {
        _prev = Cursor.Current;
        Cursor.Current = Cursors.WaitCursor;

    public void Dispose() {
        Cursor.Current = _prev;

I create the instance of the WairCursor class inside a using statement. This will automatically call the Dispose() method when it goes out of scope.

using (new WaitCursor()) {
    // long running operation, for example:

Afterwards I did some searching around on the web. Turns out I'm not the first to come up with this solution. Charlie Poole already posted it a few years ago. Another bummer.

Leave a Comment

Leave a Comment
5 + 5 =


All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.