如何使光标转向等待光标? [英] How can I make the cursor turn to the wait cursor?

查看:218
本文介绍了如何使光标转向等待光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,有用户登录到它,并且因为散列算法是昂贵的,需要一点时间做。如何显示等待/忙光标(通常是沙漏)给用户,让他们知道程序正在做什么?



项目在C# p>

解决方案

您可以使用 Cursor.Current

  //将游标设置为沙漏
Cursor.Current = Cursors.WaitCursor;

//在这里执行你的时间密集型哈希代码...

//将游标设置为默认箭头
Cursor.Current = Cursors.Default;但是,如果散列操作是真的长度(MSDN将其定义为 超过2-7秒),您应该使用光标以外的视觉反馈指示器来通知用户进度。有关更深入的指南集,请参见本文



编辑

正如@Am指出,您可能需要拨打 Application.DoEvents(); 之后 Cursor.Current = Cursors.WaitCursor; ,以确保沙漏实际显示。


I have a C# application that has users login to it, and because the hashing algorithm is expensive, it takes a little while to do. How can I display the Wait/Busy Cursor (usually the hourglass) to the user to let them know the program is doing something?

The project is in C#.

解决方案

You can use Cursor.Current.

// Set cursor as hourglass
Cursor.Current = Cursors.WaitCursor;

// Execute your time-intensive hashing code here...

// Set cursor as default arrow
Cursor.Current = Cursors.Default;

However, if the hashing operation is really lengthy (MSDN defines this as more than 2-7 seconds), you should probably use a visual feedback indicator other than the cursor to notify the user of the progress. For a more in-depth set of guidelines, see this article.

Edit:
As @Am pointed out, you may need to call Application.DoEvents(); after Cursor.Current = Cursors.WaitCursor; to ensure that the hourglass is actually displayed.

这篇关于如何使光标转向等待光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆