Created
May 5, 2014 23:50
-
-
Save jpobst/e74f97fe9204c750a8c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a class like this | |
public class AutoCursor : IDisposable | |
{ | |
private Form form; | |
public AutoCursor (Form form) | |
{ | |
this.form = form; | |
form.Cursor = System.Windows.Forms.Cursors.WaitCursor; | |
} | |
public void Dispose () | |
{ | |
if (form.Cursor == System.Windows.Forms.Cursors.WaitCursor) | |
form.Cursor = System.Windows.Forms.Cursors.Arrow; | |
} | |
} | |
// Then use it like this | |
using (new AutoCursor (this)) { | |
// Long running process here... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is so simple, yet great! I should have thought of this long ago. I didn't but I'm glad you did.