CJ7*_*CJ7 3 .net c# mouse-pointer
使用Application.UseWaitCursor关闭和打开沙漏鼠标指针是否有任何危险?
"危险"是不恢复光标.
您可以使用try…finally块来执行此操作,以确保即使抛出异常也可以恢复游标,或者通过将此功能包装在实现的类中来清理语法,IDisposable以便您可以使用using块.
public class WaitCursor : IDisposable
{
public WaitCursor()
{
Application.UseWaitCursor = true;
}
public void Dispose()
{
Application.UseWaitCursor = false;
}
}
Run Code Online (Sandbox Code Playgroud)
用法:
using (new WaitCursor())
{
// do stuff - busy, busy, busy
} // here the cursor will be restored no matter what happened
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7163 次 |
| 最近记录: |