Winfrom巧用Using设置鼠标为WaitCursor

本文转载:http://www.cnblogs.com/LoveJenny/archive/2013/03/13/2956922.html

看到try,finally ,有没有让你想到什么呢?,对了using 可以生成try-finally

Winfrom巧用Using设置鼠标为WaitCursor
public class WaitCursor : IDisposable
{
    private Cursor cursor;

    public WaitCursor()
    {
        this.cursor = Cursor.Current;
        Cursor.Current = Cursors.WaitCursor;
    }

    public void Dispose()
    {
        Cursor.Current = cursor;
    }
}
Winfrom巧用Using设置鼠标为WaitCursor

使用的时候,只需要:

Winfrom巧用Using设置鼠标为WaitCursor
private void button1_Click(object sender, EventArgs e)
{
    using(new WaitCursor())
    {
        LongTimeMethod();
    }
}
Winfrom巧用Using设置鼠标为WaitCursor
上一篇:你所不知道的http.body


下一篇:ExtJs6 loader 引入html页面不执行页面内js的解决办法