您的位置:首页 > 大数据 > 人工智能

Winfrom巧用Using设置鼠标为WaitCursor

2014-09-24 13:47 92 查看
本文转载:http://www.cnblogs.com/LoveJenny/archive/2013/03/13/2956922.html

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

public class WaitCursor : IDisposable
{
private Cursor cursor;

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

public void Dispose()
{
Cursor.Current = cursor;
}
}


使用的时候,只需要:

private void button1_Click(object sender, EventArgs e)
{
using(new WaitCursor())
{
LongTimeMethod();
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: