| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | using System;using System.Windows.Forms;namespace PaintDotNet{    /// <summary>    /// Simply sets a control's Cursor to the WaitCursor (hourglass) on creation,    /// and sets it back to its original setting upon disposal.    /// </summary>    public sealed class WaitCursorChanger        : IDisposable    {        private Control control;        private Cursor oldCursor;        private static int nextID = 0;        private int id = System.Threading.Interlocked.Increment(ref nextID);        public WaitCursorChanger(Control control)        {            this.control = control;            this.oldCursor = Cursor.Current;            Cursor.Current = Cursors.WaitCursor;        }        ~WaitCursorChanger()        {            Dispose(false);        }        public void Dispose()        {            Dispose(true);            GC.SuppressFinalize(this);        }        private void Dispose(bool disposing)        {            if (disposing)            {                if (this.oldCursor != null)                {                    Cursor.Current = this.oldCursor;                    this.oldCursor = null;                }            }        }    }}
 |