简体   繁体   中英

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. 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. Try and keep the load off your GUI thread. For the test, just run your code on a background thread.

Instead of Cursor.Current use

this.Current=Cursors.Waitcusrsor;

this.Cursor=Cursors.Default;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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