Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

I set the wait cursor using Cursor.Current = Cursors.WaitCursor;. Why does does it disappear before I want it to?

cursor disappear wait
0
Posted

I set the wait cursor using Cursor.Current = Cursors.WaitCursor;. Why does does it disappear before I want it to?

0

Setting the Current property changes the cursor and stops the processing of mouse events. Setting the cursor back to Cursors.Default restarts the mouse event processing and displays the proper cursor for each control. If a DoEvents is called before you reset the cursor back to the default, this will also start up the mouse event processing and you will lose the particular cursor you set. So, if your WaitCursor is disappearring, one explanation might be that DoEvents is getting called. Here is some code that sets a WaitCursor. Cursor oldCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { // Do your processing that takes time, e.g., wait for 2 seconds DateTime dt = DateTime.Now.AddSeconds(2); while ( dt > DateTime.Now ) {} } finally { Cursor.Current = oldCursor; } Contributed from George Shepherd’s Windows Forms FAQ, # No product version has been specified for this FAQ item. Please report status updates here.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123