使用 Application.UseWaitCursor
关闭和打开沙漏鼠标指针有什么危险吗?
最佳答案
“危险”在于不恢复光标。
您可以使用 try...finally
block 来确保即使抛出异常也能恢复游标,或者通过将此功能包装在实现 IDisposable
以便您可以使用 using
block 。
public class WaitCursor : IDisposable
{
public WaitCursor()
{
Application.UseWaitCursor = true;
}
public void Dispose()
{
Application.UseWaitCursor = false;
}
}
用法:
using (new WaitCursor())
{
// do stuff - busy, busy, busy
} // here the cursor will be restored no matter what happened
关于c# - 应该使用 Application.UseWaitCursor 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9494133/