/ Published in: C#
Expand |
Embed | Plain Text
public class HourGlass : IDisposable { public HourGlass() { Enabled = true; } public Boolean Enabled { get { return Application.UseWaitCursor; } set { if (value != Application.UseWaitCursor) { Application.UseWaitCursor = value; Form f = Form.ActiveForm; if (f != null && f.Handle != null) { //Send WM_SETCURSOR message SendMessage(f.Handle, 0x20, f.Handle, (IntPtr)1); } } } } [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern IntPtr SendMessage(IntPtr hWind,int msg,IntPtr wp, IntPtr lp); #region IDisposable Members void IDisposable.Dispose() { Enabled = false; } #endregion } //Usage { //time consuming code goes here }
You need to login to post a comment.
