Skip to content

Instantly share code, notes, and snippets.

@jpobst
Created May 5, 2014 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpobst/e74f97fe9204c750a8c3 to your computer and use it in GitHub Desktop.
Save jpobst/e74f97fe9204c750a8c3 to your computer and use it in GitHub Desktop.
// 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...
}
@rht341
Copy link

rht341 commented Jul 25, 2014

This is so simple, yet great! I should have thought of this long ago. I didn't but I'm glad you did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment