Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WaitCursor Between forms often doesn't show up

Posted on 2010-08-17
3
Medium Priority
?
1,034 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 24

Accepted Solution

by:
alexey_gusev earned 2000 total points
ID: 33455846
try

Application.DoEvents();

to force it processing all events
0
 
LVL 2

Expert Comment

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

Author Comment

by:b_levitt
ID: 33991402
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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