Skip to content

Instantly share code, notes, and snippets.

@jfromaniello
Created November 17, 2009 13:49
Show Gist options
  • Save jfromaniello/236905 to your computer and use it in GitHub Desktop.
Save jfromaniello/236905 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace Mantenimiento.ViewModels
{
/// <summary>
/// This class implements a disposable WaitCursor to
/// show an hourglass while some long-running event occurs.
/// </summary>
/// <example>
/// <![CDATA[
///
/// using (new WaitCursor())
/// {
/// .. Do work here ..
/// }
///
/// ]]>
/// </example>
public class WaitCursor : IDisposable
{
#region Data
private readonly Cursor oldCursor;
#endregion
#region Ctor
/// <summary>
/// Constructor
/// </summary>
public WaitCursor()
{
oldCursor = Mouse.OverrideCursor;
Mouse.OverrideCursor = Cursors.Wait;
}
#endregion
#region Public Methods
/// <summary>
/// Returns the cursor to the default state.
/// </summary>
public void Dispose()
{
Mouse.OverrideCursor = oldCursor;
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment