Solved

WaitCursor Between forms often doesn't show up

Posted on 2010-08-17
3
1,013 Views
Last Modified: 2013-12-21
I try to set Cursor.Current=Cursors.WaitCursor, when ever I have a long running operation.  However, I'm noticing, that sometimes it doesn't work or there is a significant delay.  The biggest culprit is when I set it before loading and showing a modal form, ie...

      Cursor.Current = Cursors.WaitCursor;
      Form formToLoad = null;
      switch (formNumber)
      {
        case "1":
          formToLoad = new App1MainMenu();
          break;
        case "2":
          formToLoad = new App2.FDEMainMenu();
          break;
      }
      if (formToLoad != null)
        formToLoad.ShowDialog();


If I break in the debugger prior to the showdialog line, it works fine.  Some ShowDialog trickery in my baseclass also works:

    private void BaseForm_Activated(object sender, EventArgs e)
    {
      Timer cursorTimer = new Timer();
      cursorTimer.Tick += new EventHandler(cursorTimer_Tick);
      cursorTimer.Interval = 500;
      cursorTimer.Enabled = true;

    }

    void cursorTimer_Tick(object sender, EventArgs e)
    {
      Cursor.Current = Cursors.Default;
      ((Timer)sender).Enabled = false;

    }


    new public DialogResult ShowDialog()
    {
      Cursor.Current = Cursors.WaitCursor;
      return base.ShowDialog();
    }


Is there a better way to do this?
0
Comment
Question by:b_levitt
3 Comments
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 500 total points
Comment Utility
try

Application.DoEvents();

to force it processing all events
0
 
LVL 2

Expert Comment

by:Raymond-Holmboe
Comment Utility
also, Cursor.Show() may work, right after you change the cursor.
0
 
LVL 11

Author Comment

by:b_levitt
Comment Utility
I appologize for the delay.  While I've not had a chance to test this fully, DoEvents did seem to work.  Cursor.Show did not.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now