简体   繁体   English

WaitCursor没有出现在C#NET CF应用程序中

[英]WaitCursor doesn't appear in a C# NET CF application

I'm running a somewhat lengthy process in a C# .NET CF application, then I want to show the hourglass mouse pointer. 我在C#.NET CF应用程序中运行了一个漫长的过程,然后我想显示沙漏鼠标指针。 The code I'm using is: 我使用的代码是:

Cursor.Current = Cursors.WaitCursor;
Cursor.Show();
this.Refresh();

for (int nRow = 0; ... // lengthy process
{
    Program.tblLect.Rows[nRow]["rowId"] = nRow + 1;
    // tried with this, doesn't work either
    //if ((nRow % 20)==0) 
    //    Application.DoEvents();
}

Cursor.Current = Cursors.Default;

but no cursor is shown in the form. 但表格中没有显示光标。

Any ideas? 有任何想法吗?

Even when calling Application.DoEvents, your application will be working ALOT and therefore is not guaranteed to update the UI. 即使在调用Application.DoEvents时,您的应用程序也可以正常运行,因此不能保证更新UI。 Try and keep the load off your GUI thread. 尝试减轻您的GUI线程的负担。 For the test, just run your code on a background thread. 对于测试,只需在后台线程上运行代码即可。

Instead of Cursor.Current use 代替Cursor.Current使用

this.Current=Cursors.Waitcusrsor; this.Current = Cursors.Waitcusrsor;

this.Cursor=Cursors.Default; this.Cursor = Cursors.Default;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM