List Info

Thread: Wait cursor - Why does does it disappear before I want it to?




Wait cursor - Why does does it disappear before I want it to?
country flaguser name
United States
2007-02-25 14:53:05
I set the wait cursor using Cursor.Current =
Cursors.WaitCursor;. Why
does does it disappear before I want it to?

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;
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopmentgooglegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribegooglegroups.com
For more options, visit this group at
http:
//cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )